Very quick question I hope someone can answer.
I'm calling sendTask() in a C++ library where I pass a char* that is
supposedly malloced and returned so I need to free() it.
The problem is when I call Safefree() below the code fails (in odd ways),
but if I don't call Safefree() /free() then it works ok.
Looking at the code below, if "buffer" is malloc'd and returned and newSVpv
*copies* the buffer into the SV then is it correct to call Safefree() or
free() as I'm doing below?
void
sendTask( MyClient * THIS, unsigned int id, char * message_payload,
unsigned int message_length )
PPCODE:
char * buffer = NULL;
int buffer_length;
int status;
THIS->sendTask( id, message_payload, message_length, buffer,
&buffer_length, &status );
XPUSHs( sv_2mortal( newSVpv( buffer, buffer_length ) ) );
* Safefree( buffer );*
XPUSHs( sv_2mortal( newSViv( status ) ) );
--
Bill Moseley
mose...@hank.org