summaryrefslogtreecommitdiffstats
path: root/Python/strdup.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-29 17:48:26 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-29 17:48:26 (GMT)
commitbae29713ec7395396463bfd7981eab392c510fe6 (patch)
tree21b8347fec813ddfe8e7ec55fbb6d78caac45a61 /Python/strdup.c
parent62cf605a04fc2a4d39fedd7ba52ec818b9524b54 (diff)
downloadcpython-bae29713ec7395396463bfd7981eab392c510fe6.zip
cpython-bae29713ec7395396463bfd7981eab392c510fe6.tar.gz
cpython-bae29713ec7395396463bfd7981eab392c510fe6.tar.bz2
*** empty log message ***
Diffstat (limited to 'Python/strdup.c')
-rw-r--r--Python/strdup.c22
1 files changed, 22 insertions, 0 deletions
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 <string.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#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;
+}