Displaying 1 result from an estimated 1 matches for "end_product".
Did you mean:
add_product
2009 Dec 21
2
Limit on number of times Realloc can be called?
...lloc" (the R version as defined in the manual
"R-extenstions" not the C version "realloc") when I try to use the
following program:
#include <R.h>
#include <Rinternals.h>
SEXP test_mem_alloc(SEXP z) {
double *t = Calloc(sizeof(double), double);
*t = 2;
SEXP end_product;
int i = 0;
for(i=1; i < 20; i++) {
t = Realloc(t, sizeof(t) + sizeof(double), double);
t[i] = i;
}
PROTECT(end_product = allocVector(REALSXP,6));
for(i = 0; i < 20; i++) {
REAL(end_product)[i] = t[i];
}
UNPROTECT(1);
Free(t);
return end_product;
}
I call it from R using the f...