Skip to content

R_alloc problems in R v1.11

2 messages · Marie-Hélène Ouellette, Peter Dalgaard

#
Dear Dr. Ripley,

I'm using the R v1.11 on Macintoch and I seem to have a problem with the
function R_alloc. It crashes when using the following .C function (only an
example):

///////////////////////////////
# include <R.h>
void Hello(int *n)
{
int i,x;
for(i=1;1< *n ; i++)
{
	Rprintf('salut!!!\n');
}
x = (int *) R_alloc(5,sizeof(int));
}

///////////////////////////////

I call it in R with this line:

.C('Hello',as.integer(5))

Any idea why and how I can resolve this problem?

Thank you for your time,
Marie-H?l?ne
#
Marie-H?l?ne Ouellette <marie-helene.ouellette at umontreal.ca> writes:
Believe it or not, there are several people on this list who are not
Dr.Ripley. In fact, I suspect that he is temporarily absent these
days. Had he been present he would likely have explained that none of
us need to read the same message five times over...
Say what? There was never an R version with that number. Is this Mac OS X
or classic Mac?
*How* does it "crash"? R shuts down? Prints an infinite stream of "salut!!!"?
What did you do to compile and did you see any warnings from the compilation?
and then what happens?
Well, if that is really your code, x is an int that gets an int *
assigned to it, but 1 is never going to be bigger than *n, so I don't
see how you'd get that far.