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

From my point of view, there is a lot of missing macro and/or typedef and C subroutine code. In particular, without seeing the typedef/macro code behind the LHS AV *arr and the code for the subroutine newAV, I find it impossible to construct reliably what is being handed down to Perl.

-M

Free your mind

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

Replies are listed 'Best First'.
Re^2: perlembed: mortalize an AV, get "Attempt to free unreferenced scalar" - don't mortalize, leaks memory
by gellyfish (Monsignor) on Jul 10, 2006 at 09:23 UTC

    You will find these things in the perl source code. newAV() is defined in av.c. The struct av is defined in sv.h and the typedef struct av AV; is in perl.h

    /J\

      I have now found a copy of the source of av.c at sourceforge updated version and my first second impression is that an explicit call to av_clear Perl_av_clear is required to free the memory.

      -M

      Free your mind

        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\