Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame^] | 1 | /* strdup() replacement (from stdwin, if you must know) */ |
2 | |||||
3 | #include "config.h" | ||||
4 | #include <string.h> | ||||
5 | |||||
6 | #ifdef HAVE_STDLIB_H | ||||
7 | #include <stdlib.h> | ||||
8 | #else | ||||
9 | extern ANY *malloc Py_PROTO((size_t)); | ||||
10 | #endif | ||||
11 | |||||
12 | char * | ||||
13 | strdup(str) | ||||
14 | const char *str; | ||||
15 | { | ||||
16 | if (str != NULL) { | ||||
17 | register char *copy = malloc(strlen(str) + 1); | ||||
18 | if (copy != NULL) | ||||
19 | return strcpy(copy, str); | ||||
20 | } | ||||
21 | return NULL; | ||||
22 | } |