blob: 0ea9603d8017cc5990266c4463f367e97355bae1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
cdef char* strdup (char * other) except NULL:
cdef size_t len
cdef char* new
if other is NULL:
return NULL
len = strlen(other)
new = <char*>PyMem_Malloc(len+1)
if new is NULL:
raise MemoryError, "Malloc of new string copy"
return NULL
return strcpy(new, other)
|