From saptarshi.guha at gmail.com  Mon Aug 24 05:52:28 2009
From: saptarshi.guha at gmail.com (Saptarshi Guha)
Date: Sun, 23 Aug 2009 23:52:28 -0400
Subject: [Rd] Basic Question regarding PROTECT
Message-ID: <1e7471d50908232052y1f4ae6e5p57ad8c9f213ef611@mail.gmail.com>

Hello,
Suppose I have the function
SEXP foo(){
SEXP s;
PROTECT(s=allocVector(...))

....
UNPROTECT(1);
return(s)
}

y=foo() // foo is a recusrive call

Q: Am i correct in understanding that one does not need to write
PROTECT(y=foo()) ?(and a corresponding unprotect  later on)
since it is the object that is protected , SEXP is an alias for
SEXPREC* and allocVector probably does some memory allocation which
does not get freed
when foo returns.

Thank you for your time
Regards
Saptarshi



[Rd] Basic Question regarding PROTECT
Saptarshi Guha