https://github.com/python/cpython
Raw File
Tip revision: ccb0e6a3452335a4c3e2433934c3c0c5622a34cd authored by Ɓukasz Langa on 15 November 2021, 17:26:38 UTC
Python 3.9.9
Tip revision: ccb0e6a
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