Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: XS malloc and free

by Courage (Parson)
on Feb 07, 2006 at 16:21 UTC ( #528552=note: print w/replies, xml ) Need Help??

in reply to XS malloc and free

from perldoc perlguts
To free an SV that you've created, call "SvREFCNT_dec(SV*)". Norma +lly this call is not necessary (see "Reference Counts and Mortality").
You do not free SV, you decrement its usage, and, when refcount goes to zero, it will be destroyed, and may be some destruction-time action will be activated

addition to free memory out from external library, consult that library's logic. Perl do not uses external char*, it will copy its data into newly created SV

Best regards,
Courage, the Cowardly Dog

Replies are listed 'Best First'.
Re^2: XS malloc and free
by ikegami (Pope) on Feb 07, 2006 at 19:02 UTC

    He's not asking about freeing the SV. He asking about freeing the string from which he created an SV.

    Furthermore, SvREFCNT_dec should not be used here. Making the SV mortal (using sv_2mortal) will automatically free the SV at the end of the XSUB. Think of sv_2mortal as a delayed SvREFCNT_dec.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://528552]
[Lotus1]: damn, I just opened the attacment on a phishing simulation email in the $work email
[Lotus1]: now I'll be sent to re-education camp or something
[stevieb]: relocate Lotus1 to the brig, straight away!
[erix]: let's do an education simulation
[stevieb]: You could just play dumb... "huh? There was no mention of 'fishing' in the email!"
[erix]: you could say you were part of the simulation
[stevieb]: I'd take full responsibility myself... "man, I was so hung over I could barely read what the email said!"

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2017-05-24 13:45 GMT
Find Nodes?
    Voting Booth?