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" |
Guido van Rossum | 927f6e6 | 1996-08-29 18:10:30 +0000 | [diff] [blame] | 4 | #include "myproto.h" |
| 5 | #include "mymalloc.h" |
Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | 927f6e6 | 1996-08-29 18:10:30 +0000 | [diff] [blame] | 7 | #include <string.h> |
Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 8 | |
| 9 | char * |
| 10 | strdup(str) |
| 11 | const char *str; |
| 12 | { |
| 13 | if (str != NULL) { |
| 14 | register char *copy = malloc(strlen(str) + 1); |
| 15 | if (copy != NULL) |
| 16 | return strcpy(copy, str); |
| 17 | } |
| 18 | return NULL; |
| 19 | } |