From bae29713ec7395396463bfd7981eab392c510fe6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 29 Aug 1996 17:48:26 +0000 Subject: *** empty log message *** --- Python/strdup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Python/strdup.c diff --git a/Python/strdup.c b/Python/strdup.c new file mode 100644 index 0000000..5198e25 --- /dev/null +++ b/Python/strdup.c @@ -0,0 +1,22 @@ +/* strdup() replacement (from stdwin, if you must know) */ + +#include "config.h" +#include + +#ifdef HAVE_STDLIB_H +#include +#else +extern ANY *malloc Py_PROTO((size_t)); +#endif + +char * +strdup(str) + const char *str; +{ + if (str != NULL) { + register char *copy = malloc(strlen(str) + 1); + if (copy != NULL) + return strcpy(copy, str); + } + return NULL; +} -- cgit v0.12