Skip to content
Prev 82732 / 398506 Next

correct C function usage

On Tuesday 13 December 2005 22:35, you wrote:
Thats undefined - probably a segmentation fault. 

Thank you very much for your answers.

I was trying to cut down my actual function so readers could focus
on what I was seeing as the main problem: terminating the array.
I was hoping that somebody would tell me that I only have to terminate
the array in the C function somehow and the R part would recognize
that automagically - and no more passing lengths explicitly around and 
copying arrays up to  length - e.g (ignoring wrong arguments):

void testFill(int *values, int *newvalues ){
         newvalues[0] = 1;
         newvalues[1] = 2;
         newvalues[2] =  '\0';
 }

testTestFill <- function(){
  realfilled <- testFillC( 1:10 ) 
  return(realfilled)
 }

testFillC <- function(a){
 .C("testFill", as.integer(a), newvalues=integer(length(a)))$newvalues
 }

But I tried this and it does not help.

sincerely, 
Ido Tamir