Where can I find the definition of Rf_protect () in R sources?

I read the sources of R and try to find out about the structure of the heap. I am looking for the definition of PROTECT (), but I based:

$ grep -rn "#define PROTECT(" * src/include/Rinternals.h:642:#define PROTECT(s) Rf_protect(s) 

and then

 $ grep -rn "Rf_protect(" * src/include/Rinternals.h:803:SEXP Rf_protect(SEXP); src/include/Rinternals.h:1267:SEXP Rf_protect(SEXP); 

But I did not find the definition of Rf_protect ().

Thanks.

+6
source share
1 answer

The prefix Rf_ is a common idiom that gives this simple C code a namespace similarity. So you want to look for protect(...) instead of:

 /usr/share/R/include/Rinternals.h:#define protect Rf_protect 

And considering how this is the "core", you can start with src/main , where a quick grep -c will lead you to src/main/memory.c . Et voila in lines 3075 to 3081

 SEXP protect(SEXP s) { if (R_PPStackTop >= R_PPStackSize) R_signal_protect_error(); R_PPStack[R_PPStackTop++] = CHK(s); return s; } 

Now that you have said, you probably want to pay attention to most of the file, not just this function.

+7
source

All Articles