muppet wrote:

>Steve Hay said:
>  
>
>>muppet wrote:
>>
>>    
>>
>>>according to the docs for sv_usepvn(), that sounds right.  however,
>>>it's very mind-bending and obfuscated.  you're transferring the
>>>ownership of the memory to the SV, but still cleaning it up what it
>>>points to yourself.  i can't help but ask "why?"
>>>
>>>      
>>>
>>I'm not cleaning up what it points to.  As I said, the Safefree(foo) was
>>deliberately commented-out.  I'm cleaning up foo->buf because that was
>>separately allocated and hasn't been "taken over" by the SV.
>>    
>>
>
>what i meant was that you're cleaning up the memory pointed to by the object
>pointed to by foo.   that's a hard way to say it.  ;-)
>
>basically,  FooNew() allocates some deep structure, and FooFree() only frees
>*part* of that structure; this design is confusing.
>
I agree.  I was going to come on to that next, but wanted to fix the 
leak first :)

So: I've entrusted managemnt of foo's memory to Perl by placing it in 
the SV, but I still have to free up anything else that was allocated and 
is pointed to from within foo.  Is there any way to have Perl free the 
members of foo when it frees foo, so that the whole struct is freed 
instead of just the outer bit?

- Steve



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender immediately.  The 
unauthorized use, disclosure, copying or alteration of this message is strictly 
forbidden.  Note that any views or opinions presented in this email are solely those 
of the author and do not necessarily represent those of Radan Computational Ltd.  The 
recipient(s) of this message should check it and any attached files for viruses: Radan 
Computational will accept no liability for any damage caused by any virus transmitted 
by this email.

Reply via email to