Re: [Rd] Why no race condition when returning UNPROTECT-ed memory from C?

2010-04-14 Thread peter dalgaard
On Apr 14, 2010, at 7:50 AM, Dominick Samperi wrote: Consider the C (or C++) code called from the .Call interface: SEXP foo() { SEXP *p = PROTECT(allocVector(REALSXP, 10)); ... UNPROTECT(1); return p; } Why is there no danger that the allocated memory will be garbage collected

[Rd] Why no race condition when returning UNPROTECT-ed memory from C?

2010-04-13 Thread Dominick Samperi
Consider the C (or C++) code called from the .Call interface: SEXP foo() { SEXP *p = PROTECT(allocVector(REALSXP, 10)); ... UNPROTECT(1); return p; } Why is there no danger that the allocated memory will be garbage collected after the UNPROTECT, but before the return of p? I have used