blob: 5198e25e087734ed66f121def81af950ad61ea1f [file] [log] [blame]
Guido van Rossumbae29711996-08-29 17:48:26 +00001/* strdup() replacement (from stdwin, if you must know) */
2
3#include "config.h"
4#include <string.h>
5
6#ifdef HAVE_STDLIB_H
7#include <stdlib.h>
8#else
9extern ANY *malloc Py_PROTO((size_t));
10#endif
11
12char *
13strdup(str)
14 const char *str;
15{
16 if (str != NULL) {
17 register char *copy = malloc(strlen(str) + 1);
18 if (copy != NULL)
19 return strcpy(copy, str);
20 }
21 return NULL;
22}