Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by vr (Curate)
on Aug 01, 2015 at 11:28 UTC ( [id://1137105]=note: print w/replies, xml ) Need Help??


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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1137105]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found