Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bae2971

Browse files
committed
*** empty log message ***
1 parent 62cf605 commit bae2971

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Python/strdup.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* 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
9+
extern ANY *malloc Py_PROTO((size_t));
10+
#endif
11+
12+
char *
13+
strdup(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+
}

0 commit comments

Comments
 (0)