From vograno at evafunds.com  Tue Apr 12 21:31:03 2005
From: vograno at evafunds.com (Vadim Ogranovich)
Date: Tue Apr 12 21:31:57 2005
Subject: [Rd] How allocate STRSXP outside of gc
Message-ID: <C698D707214E6F4AB39AB7096C3DE5A59E8922@phost015.EVAFUNDS.intermedia.net>

Hi,
 
I am trying to figure a way to allocate a string SEXP so that gc() won't
ever collect it.
 
Here is a little bit of a background. Suppose I want to write a
.Call-callable function that upon each call returns the same value, say
mkChar("foo"):
 
SEXP getFoo() {
   return mkChar("foo");
}
 
The above implementation doesn't take advantage of the fact that
mkChar("foo") could be pre-computed only once, and then the function
would return the pre-computed value. So the question is how to create
this precomputed value.
 
 
The closest thing I could find in the sources is R_NaString, but I was
not able to trace down how it comes about.
 
 
Thanks,
Vadim
 
 
P.S. I was able to solve a similar problem with symbols. If I need a
symbol "foo", I do
 
static SEXP  FooSymbol = install("foo");
 
and then use FooSymbol instead of install("foo")
 
 
 

	[[alternative HTML version deleted]]


[Rd] How allocate STRSXP outside of gc
Vadim Ogranovich