List:NDB Connectors« Previous MessageNext Message »
From:Mika Raento Date:April 24 2007 11:17am
Subject:binary strings
View as plain text  
%extend NdbRecAttr {

   %cstring_output_allocate_size(char ** s, int *slen, void())
   void string_value(char ** s, int *slen) {
     char* ref=self->aRef();
     *slen=ref[0];
     ref++;
     *s=ref;
   }

};

works nicely for strings that don't contain embedded NULLs. The problem 
is that there is a bug in SWIG_FromCharPtrAndSize for perl in 1.3.31 
(and everything before that) that it doesn't actually use the size, but 
calls sv_setpv which uses strlen(). See 
http://permalink.gmane.org/gmane.comp.programming.swig.devel/16349

The way to fix is to either:
1) modify your local SWIG installation
2) see if SWIG svn works
3) copy the typemap with a different name for SWIG_FromCharPtrAndSize 
and copy the corrected function too

None of which are really good. I'm going with 1) for now myself.

I can't find any docs for %fragment. I'm wondering whether there would 
be a way to override the SWIG_FromCharPtrAndSize fragment.

     Mika
Thread
binary stringsMika Raento24 Apr