https://github.com/python/cpython
Raw File
Tip revision: c1004b85464579771db3b50f5b150449275bbbd0 authored by Ɓukasz Langa on 06 May 2019, 18:30:25 UTC
Python 3.8.0a4
Tip revision: c1004b8
strdup.c
/* strdup() replacement (from stdwin, if you must know) */

char *
strdup(const char *str)
{
    if (str != NULL) {
        char *copy = malloc(strlen(str) + 1);
        if (copy != NULL)
            return strcpy(copy, str);
    }
    return NULL;
}
back to top