Skip to content
Prev 16568 / 63424 Next

memory allocation problem under linux

Scrive Prof Brian Ripley <ripley at stats.ox.ac.uk>:
Sorry for the repeated post (in 2 different mailing lists).
Tnx for your suggestion. Now I think I've found the problem. Try this:
////file foo.c
#include <R.h>
int **box;
void foo(){
  int i;
  box =   (int**)R_alloc(1,   sizeof(int *));
}
/////////////
Compiled with R CMD SHLIB foo.c
In R:
*Segmentation fault*
The problem disappears when the declaration of 'box' comes inside the function
foo... Is this a bug?

Antonio, Fabio Di Narzo.