From saptarshi.guha at gmail.com  Mon Mar 30 03:45:43 2009
From: saptarshi.guha at gmail.com (Saptarshi Guha)
Date: Sun, 29 Mar 2009 21:45:43 -0400
Subject: [Rd] Setting the names attribute of a list?
Message-ID: <1e7471d50903291845n1d37356i57ec2124ebc5047e@mail.gmail.com>

Hello,
I have created a vector with 2 elements(see code below)
I am calling this function many thousands of times (hundreds of
thousands) after some time
i get
 *** caught segfault ***
address 0x5, cause 'memory not mapped'
However, if i dont set the R_NamesSymbol, I do not get any such error.
Am I doing this correctly?

Thank you
Saptarshi

==CODE===

// kxp and usar are two SEXP's which have not been protected
SEXP res
PROTECT(res);
res= allocVector(VECSXP, 2);
SET_VECTOR_ELT(res,0,kxp);
SET_VECTOR_ELT(res,1,usar);

names=allocVector(VECSXP,2);PROTECT(names); //A
SET_VECTOR_ELT(names, 0, mkChar("key")); //A
SET_VECTOR_ELT(names, 1, mkChar("value")); //A
setAttrib(res, R_NamesSymbol,names); //A
UNPROTECT(2);
return(res);


Saptarshi Guha



[Rd] Setting the names attribute of a list?
Saptarshi Guha