Python/SWIG: GC Object already tracked when trying to use a C function to dereference a pointer, from SWIG -


i have issue i'm dealing words (2 byte unsigned integers). here commands run

import mysimlib mysimlib.init() strptr = mysimlib.strinit( 200 )    #where 200 number of characters want in                            #string. strinit returns malloc'd pointer wptr = mysimlib.wordinit ()         # wordinit returns malloc'd pointer word. mysimlib.write ("title", "data", 4) # 4 number of bytes required store data mysimlib.search ("title", strptr, 200, wptr) #search finds record same title,       #copies data strptr number of bytes in record - long       #the number of bytes in strptr greater.   mysimlib.printword (wptr) #since cannot use python dereference word pointers, call c function print out.  

at point, program crashes. throws exception (reading violation) or gc object tracked error. thing - have string print function never fails when have print. when try word print, errors.

this wordptr initiating function:

unsigned int * wordinit () {     unsigned int * d = malloc ( sizeof ( unsigned int ) );     *d = 0;     return d; } 

this printing function:

void wordprint (unsigned int * d){     printf ("\nwptr: %d",*d); } 

i've no idea i'm doing wrong here these crashes erratic , annoying.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -