in reply to Re: Trying dirty trick with Imager and Inline C, but having difficulties. Can you help?
in thread Trying dirty trick with Imager and Inline C, but having difficulties. Can you help?

I was hoping to avoid copying i.e. re-use allocated string data. Thanks to your tip, I think a working solution can be:

void _replace( Imager img, SV* str ) { sv_force_normal( str ); unsigned char* ptr = SvPV_nolen( str ); myfree( img-> idata ); img-> idata = ptr; SvPV_set( str, savepv( "" ) ); }

It works, though I'm still not sure, is it really OK? Or too ugly? Or scandalously incorrect and will bite me some time later?

  • Comment on Re^2: Trying dirty trick with Imager and Inline C, but having difficulties. Can you help?
  • Download Code

Replies are listed 'Best First'.
Re^3: Trying dirty trick with Imager and Inline C, but having difficulties. Can you help?
by Anonymous Monk on Aug 02, 2015 at 07:50 UTC
      Thank you. Yes, it works with Strawberry 5.20.2, gcc 4.8.3 (i686-w64-mingw32).