blob: 769d3db130988c6c6bc898ffecaeaa9fa11ac038 [file] [log] [blame]
Guido van Rossumbae29711996-08-29 17:48:26 +00001/* strdup() replacement (from stdwin, if you must know) */
2
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00003#include "pgenheaders.h"
Guido van Rossumbae29711996-08-29 17:48:26 +00004
5char *
Thomas Woutersf70ef4f2000-07-22 18:47:25 +00006strdup(const char *str)
Guido van Rossumbae29711996-08-29 17:48:26 +00007{
8 if (str != NULL) {
Antoine Pitrou9ed5f272013-08-13 20:18:52 +02009 char *copy = malloc(strlen(str) + 1);
Guido van Rossumbae29711996-08-29 17:48:26 +000010 if (copy != NULL)
11 return strcpy(copy, str);
12 }
13 return NULL;
14}