[R] memory allocation problem under linux

From: <antonio.dinarzo_at_studio.unibo.it>
Date: Sun 12 Jun 2005 - 22:17:27 EST


I have some compiled code that works under winXp but not under linux (kernel 2.6.10-5). I'm also using R 2.1.0
After debugging, I've discovered that this code:   #define NMAX 256
  long **box;
...

  box = (long **)R_alloc(NMAX, sizeof(long *));

gives a null pointer, so subsequent line:   for (i=0; i<NMAX; i++) box[i] = (long *) R_alloc(NMAX, sizeof(long)); gives a SIGSEGV signal.
In the same shared library, I have a function with this code:   partitions=16;
...

  h2=(long **)R_alloc(partitions,sizeof(long *));   for (i=0;i<partitions;i++)

      h2[i]=(long *)R_alloc(partitions,sizeof(long)); that works! Naturally, I've tried to change NMAX from 256 to 16, without any success.

Any idea on where the problem can reside? (Note that this not happens under WinXp). And just another question. When R_alloc fails, should-it terminate the function with an error, without returning control to the function?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jun 12 22:21:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:33 EST