Thanks for your response, Mark.

The perlapi documentation states:

            The return value will be NULL if the operation failed or if the
            value did not need to be actually stored within the array (as in
            the case of tied arrays). Otherwise it can be dereferenced to
            get the original `SV*'. Note that the caller is responsible for
            suitably incrementing the reference count of `val' before the
            call, and decrementing it if the function returned NULL.

So I want to see if it returned NULL, but I don't know how.  If I try:

  svReturnVal = av_store(avArray, 2, svNewVal); //svReturnVal is an SV**

and then: 

  iReturnVal = SvIV(*svReturnVal); //iReturnVal is an int

I get the "assignment from incompatible pointer type" error.  How do I
dereference the thing to see if it returned null or not?



> -----Original Message-----
> From: Mark Mielke [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 02, 2001 5:01 PM
> To: Kort, Eric
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: How do I capture the return value of av_store?
> 
> 
> av_store() doesn't return success vs. failure. It returns a pointer to
> the SV as it shows up within the array itself.
> 
> av_store() can be assumed to be successful, as if it were to fail, it
> would die().
> 
> mark
> 
> 
> On Fri, Mar 02, 2001 at 04:39:34PM -0500, "Kort, Eric" wrote:
> > Can someone help me understand how to capture the return 
> value of av_store?
> > Here is a short snippet illustrating what I am trying to do 
> (in the context
> > of a larger procedure wherein the use of av_store actually 
> makes sense):
> > 
> > void update(SV* svArray)
> > {
> >   AV* avArray;
> >   SV* svNewVal;
> >   int iNewVal;
> > 
> >   avArray = (AV*)SvRV(svArray);
> >   iNewVal = 3;
> >   svNewVal = newSViv(iNewVal);
> >   av_store(avArray, 2, svNewVal);
> > }
> > 
> > This works, but want I want to do is check the return value 
> of av_store, an
> > SV**, to make sure it suceeded, and then increment the 
> reference count of
> > svNewVal if it did.  I tried something like:
> > 
> >   SV* *svReturnVal
> > 
> > and then
> > 
> >   svReturnVal = av_store(avArray, 2, svNewVal);
> > 
> > but that produces the error "assignment from incompatible 
> pointer type".
> > What is the proper way to capture the return and ensure it 
> is not NULL?
> > 
> > Thanks,
> > Eric

Reply via email to