diff options
author | Guido van Rossum <guido@python.org> | 1996-08-29 17:48:26 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-08-29 17:48:26 +0000 |
commit | 62bed7a071819c39ae446f990b9d268847237d1d (patch) | |
tree | 0860a3afac88435e12af0255b202a8affa6e8ad3 /Python/strdup.c | |
parent | 230b308fa6f2f513871686ba29914b04aacc0ee2 (diff) | |
download | cpython-62bed7a071819c39ae446f990b9d268847237d1d.tar.gz |
*** empty log message ***
Diffstat (limited to 'Python/strdup.c')
-rw-r--r-- | Python/strdup.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Python/strdup.c b/Python/strdup.c new file mode 100644 index 0000000000..5198e25e08 --- /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; +} |