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 | { |
| 8 | if (str != NULL) { |
Antoine Pitrou | 9ed5f27 | 2013-08-13 20:18:52 +0200 | [diff] [blame] | 9 | char *copy = malloc(strlen(str) + 1); |
Guido van Rossum | bae2971 | 1996-08-29 17:48:26 +0000 | [diff] [blame] | 10 | if (copy != NULL) |
| 11 | return strcpy(copy, str); |
| 12 | } |
| 13 | return NULL; |
| 14 | } |