From: William S F. <ws...@fu...> - 2010-04-29 19:30:46
|
Rob Marshall wrote: > Hi, > > I have a library with a function that looks like: > > deleteLockFile(int fd, char *name); > > I need to rename it because the library routine > unlinks the lock file and then frees the 'name' > string. The problem is that because I passed > the name out to Python, and now it's coming back > in, the address isn't valid and the free() is > crashing the application. > > I did a %rename, e.g.: > > %rename(deleteLockFile) pyDeleteLockFile; > The signatures are not identical when you include the parameter list else C++ compiler wouldn't allow the two methods to compile as overloaded methods. Read the docs on %rename and use the parameter lists. > But because the signatures are identical swig is > creating SWIG_0 and SWIG_1 versions with SWIG_0 > being the library version. Since it has precedence > in wrapped code the library function is always > getting called. > I don't follow. Please supply a small reproducable example of your problem. > Is there a way to force swig to use my function > as SWIG_0? i.e. to change the precedence so that > it calls pyDeleteLockFile? > > I know that I can break up the build process in > some fashion so that the swig is done, then use > sed on the _wrap.c to change it, but there really > has to be a better way...at least I hope there > is :-) Indeed there should be if you give us some more info! William |