|
27 | 27 | #include "internal.h" |
28 | 28 | #include <Rcpp/cache.h> |
29 | 29 | #include <algorithm> |
| 30 | +#include <Rcpp/protection/Shield.h> |
| 31 | + |
30 | 32 |
|
31 | 33 | SEXP get_string_elt(SEXP x, int i){ |
32 | 34 | return STRING_ELT(x, i ) ; |
@@ -77,7 +79,7 @@ SEXP get_rcpp_cache() { |
77 | 79 | if( ! Rcpp_cache_know ){ |
78 | 80 |
|
79 | 81 | SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table |
80 | | - Shield<SEXP> RCPP( Rf_eval(Rf_lang2( getNamespaceSym, Rf_mkString("Rcpp") ), R_GlobalEnv) ) ; |
| 82 | + Rcpp::Shield<SEXP> RCPP( Rf_eval(Rf_lang2( getNamespaceSym, Rf_mkString("Rcpp") ), R_GlobalEnv) ) ; |
81 | 83 |
|
82 | 84 | Rcpp_cache = Rf_findVarInFrame( RCPP, Rf_install(".rcpp_cache") ) ; |
83 | 85 | Rcpp_cache_know = true ; |
@@ -117,8 +119,8 @@ SEXP set_current_error(SEXP cache, SEXP e){ |
117 | 119 |
|
118 | 120 | SEXP init_Rcpp_cache(){ |
119 | 121 | SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table |
120 | | - Shield<SEXP> RCPP( Rf_eval(Rf_lang2( getNamespaceSym, Rf_mkString("Rcpp") ), R_GlobalEnv) ) ; |
121 | | - Shield<SEXP> cache( Rf_allocVector( VECSXP, RCPP_CACHE_SIZE ) ); |
| 122 | + Rcpp::Shield<SEXP> RCPP( Rf_eval(Rf_lang2( getNamespaceSym, Rf_mkString("Rcpp") ), R_GlobalEnv) ) ; |
| 123 | + Rcpp::Shield<SEXP> cache( Rf_allocVector( VECSXP, RCPP_CACHE_SIZE ) ); |
122 | 124 |
|
123 | 125 | // the Rcpp namespace |
124 | 126 | SET_VECTOR_ELT( cache, 0, RCPP ) ; |
@@ -172,7 +174,7 @@ int* get_cache( int m){ |
172 | 174 | SEXP hash_cache = VECTOR_ELT( cache, RCPP_HASH_CACHE_INDEX) ; |
173 | 175 | int n = Rf_length(hash_cache) ; |
174 | 176 | if( m > n ){ |
175 | | - Shield<SEXP> new_hash_cache( Rf_allocVector( INTSXP, m) ) ; |
| 177 | + Rcpp::Shield<SEXP> new_hash_cache( Rf_allocVector( INTSXP, m) ) ; |
176 | 178 | hash_cache = new_hash_cache ; |
177 | 179 | SET_VECTOR_ELT(cache,RCPP_HASH_CACHE_INDEX, hash_cache); |
178 | 180 | } |
|
0 commit comments