[R] memory allocation problem under linux

2005-06-12 Thread [EMAIL PROTECTED]
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; iNMAX; 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;ipartitions;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


[R] memory allocation problem under linux

2005-06-12 Thread [EMAIL PROTECTED]
I've written:

  #define NMAX 256
  long **box;
  ...
  box   = (long **)R_alloc(NMAX,   sizeof(long *));
gives a null pointer, so subsequent line:
  for (i=0; iNMAX; i++) box[i] = (long *) R_alloc(NMAX, sizeof(long));
gives a SIGSEGV signal.

Sorry, that's not exact: I have a segmentation fault just *inside* R_alloc!
Substituting R_alloc with malloc and Calloc gives the same error.

__
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