Calling a sub from perl, if this sub return an address on an array,
it is not a problem, perl seems to manage correctly the memory to
keep allocated, and I can access to the data through the reference
at any time.

Making the same call from a CPP method seems not to work.
If I quit the method and keep a value of the returned reference
of the array, a future call to a method trying to access to the
array scratches.
It looks loke that the memory has been desallocated !

Am I correct ?
Is thera way to aoid this problem by keeping the memory a live ?

I could guess that you're not incrementing the reference count of the SVs when
you store them in the AV, but please show your code as there could be many
things wrong here.

You are right, That was my first idea, but then I did not see how I
could increment the reference, so I works around, and every that I was
doing inside the SP was OK, I though that was because the SP.
So this wrong.
It means that I am doing something correct, probably when I affect
the reference:
I do:
AV* av ;

then av = (AV*) svRV (retval) ;

I probably need to create the AV more properly !!

Regards.

--
---
==========================================================================
 Patrick DUPRÉ                      |   |
 Department of Chemistry            |   |    Phone: (44)-(0)-1904-434384
 The University of York             |   |    Fax:   (44)-(0)-1904-432516
 Heslington                         |   |
 York YO10 5DD  United Kingdom      |   |    email: [EMAIL PROTECTED]
==========================================================================
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/

Reply via email to