C API String Parsing/Returning

Christian Heimes lists at cheimes.de
Mon Apr 6 09:43:30 EDT 2009


Gerhard Häring wrote:
> char* buf = strdup(s);
> if (!buf) {
>     PyErr_SetString(PyExc_MemoryError, "Out of memory: strdup failed");
>     return NULL;
> }
> 
> /* TODO: your string manipulation */

Don't forget to free(buf). ;)

Christian




More information about the Python-list mailing list