[Pyrex] wrapping structs containing pointers and functions that
allocate memory to a pointer
Nathaniel Haggard
natester at gmail.com
Wed Jun 15 22:18:41 CEST 2005
Ok here is a specific problem.
cdef struct alist:
short type
cdef struct struct_lctxt:
trc *r
unsigned f
alist *si
arr vars
ctypedef struct_lctxt lctxt
Alist is really the head of a linked list (which may contain other
linked lists) and it contains a *next ptr in the C code of the alist
struct. There is an extension like this:
cdef class nl:
cdef alist *args
cdef lctxt *lex
which contains methods for creating a new lctxt and also for creating
a new (malloc) alist. I wrapped the code do dump the contents of args
and it is called dump_alist. I run dump_alist once before passing the
lex struct to a wrapped c routine and once in the first line of the c
routine and the output is different between those two dumps. The
strings get munged or just go blank while other data is preserved.
It looks as though memory is changing when the struct * gets passed to
the routine. Why would this be happening? What programs can you
recommend for watching memory or should I just compile pyrex c output
with symbols and run gdb?
Thanks,
Nate
On 6/15/05, Andreas Kostyrka <andreas at kostyrka.org> wrote:
> Am Dienstag, den 14.06.2005, 14:13 +1200 schrieb Greg Ewing:
> > Nathaniel Haggard wrote:
> >
> > > struct alpha {
> > > char *name;
> > > alpha *next;
> Worse, this looks like C++ to me ;)
>
> Andreas
>
>
>
> BodyID:159340821.2.n.logpart (stored separately)
>
>
More information about the Pyrex
mailing list