https://github.com/python/cpython
Raw File
Tip revision: 0b1a1c8c4c556169799f027a39950de78d726b47 authored by Ɓukasz Langa on 08 June 2020, 18:41:34 UTC
Python 3.9.0b2
Tip revision: 0b1a1c8
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