Mercurial > cpython-lru_cache-weakref
view Python/strdup.c @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | bb5b9ff72de1 |
| children | 8efa37a770c6 |
line wrap: on
line source
/* strdup() replacement (from stdwin, if you must know) */ #include "config.h" #include "myproto.h" #include "mymalloc.h" #include <string.h> char * strdup(str) const char *str; { if (str != NULL) { register char *copy = malloc(strlen(str) + 1); if (copy != NULL) return strcpy(copy, str); } return NULL; }
