Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 1 | /* strdup() replacement (from stdwin, if you must know) */ |
| 2 | |
Guido van Rossum | 54ecc3d | 1999-01-27 17:53:11 +0000 | [diff] [blame] | 3 | #include "pgenheaders.h" |
Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 4 | |
| 5 | char * |
Thomas Wouters | f70ef4f | 2000-07-22 18:47:25 +0000 | [diff] [blame] | 6 | strdup(const char *str) |
Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 7 | { |
Serhiy Storchaka | 598ceae | 2017-11-28 17:56:10 +0200 | [diff] [blame] | 8 | if (str != NULL) { |
| 9 | char *copy = malloc(strlen(str) + 1); |
| 10 | if (copy != NULL) |
| 11 | return strcpy(copy, str); |
| 12 | } |
| 13 | return NULL; |
Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 14 | } |