Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory

by gellyfish (Monsignor)
on Jul 10, 2006 at 13:37 UTC ( #560139=note: print w/ replies, xml ) Need Help??


in reply to Re^3: perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory
in thread perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory

You probably actually wanted a more recent copy of the source. av_clear doesn't free the memory allocated to the array nor does it free the SVs that form its elements. It simply truncates the array.

/J\


Comment on Re^4: perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory
Download Code
Re^5: perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory
by Moron (Curate) on Jul 10, 2006 at 14:44 UTC
    Amended accordingly (studying the version you cite av_clear appears to have been renamed to Perl_av_clear and the new av_clear has another purpose).

    -M

    Free your mind

      Er, in the perl API all the public functions are defined as Perl_<whatever> and documented without the Perl_ prefix, they are also available without the prefix through macros defined in embed.h. This was the case equally for the 5.6 MacPerl source that you originally looked at. I pointed you at the APC repository not because there was any particular difference in that function (except for some tidying and type changes they are largely identical between the two versions,) but simply because the MacPerl source you pointed to is more than four years old and based on the 5.6 source, whereas the APC reflects the current versions of Perl.

      /J\

        Er, no and I don't want to continue this OT discussion.

        update Unfortunately it appears from the advice of a janitor I have to be clearer. A perusal of the two code versions shows clearly that 'cleanup' doesn't cover it. Nor does the commenting in the code support this hypothesis. It looks more like a wishful guess motivated by the desire not to change an earlier conclusion at all costs, this notwithstanding disinforming the OP.

        -M

        Free your mind

Re^5: perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory
by demerphq (Chancellor) on Jul 11, 2006 at 09:57 UTC

    nor does it free the SVs that form its elements

    moron is partially correct, it does free the SV's that form its elements. Although indirectly via refcount decrement. Thats what the follow code does:

    while (index) { SV * const sv = ary[--index]; /* undef the slot before freeing the value, because a * destructor might try to modify this array */ ary[index] = &PL_sv_undef; SvREFCNT_dec(sv); }
    ---
    $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-12-20 05:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls