mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
*** empty log message ***
This commit is contained in:
parent
62cf605a04
commit
bae29713ec
1 changed files with 22 additions and 0 deletions
22
Python/strdup.c
Normal file
22
Python/strdup.c
Normal file
|
@ -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;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue