blob: 99dc77417bd6d17f34e43aaa3e74ed6e43a1e835 [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{
Serhiy Storchaka598ceae2017-11-28 17:56:10 +02008 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 Rossumbae29711996-08-29 17:48:26 +000014}