UPDATE: Okay I've narrowed the problem down. Within my C routine I use the
getopt() method from <getopt.h>. For some reason when I recall this routine
via my .Call, getopt() hasn't "refreshed" that is it still points to the end
of my parsed command line arguments. Is R keeping this function alive in
memory? Is that why its retaining its previous values? How can I get R to
terminate this routine and reless its memory?
Thanks again for any suggetions!
Original Email ---
Hello:
I have a general question about memory allocation. I'm having a problem
with an R function -- call it myRfunction -- that calls a C routine using
.Call. For some reason it works the first time I call it, but for every
subsequent time it doesn't. I'm thinking this has to be a memory allocation
issue. If I quit R and then reload my package containing myRfunction, again
it works only the first time its called.
Here's how I allocate memory with in the C routine.
for( i=0; i<argC; i++){
argV[i] = R_alloc(strlen(CHAR_STRING_ELT(argv,i))), sizeof(char)) :
strcpy( argV[i], CHAR(STRING_ELT(argv,i))) ;
}
Can anyone give me some suggestions about how to debug this issue to see if
its indeed a memory problem? Could it be anything else?
Should I look into vmax, vmaxset etc ?
Thanks to everyone in advance for your help!
Greg
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel