[Pyrex] Pyrex and char *x[]

Greg Ewing greg.ewing at canterbury.ac.nz
Wed May 16 11:21:10 UTC 2007


Georg Grabler wrote:

> Since i'm experiencing problems with the memcpy, i didn't use it. Does
> this mean, that i actually could come into troubles for python
> releasing my objects in the structure?

Yes. When Pyrex converts a Python string to a C string,
it just gives you a "borrowed" C pointer to the internals
of the Python string. Python has no idea that this
borrowed reference exists, so there is a danger that
the Python string will be deallocated and the C pointer
left dangling.

--
Greg



More information about the Pyrex mailing list