Skip to content

Commit fc83025

Browse files
committed
Using vmaxget/vmaxset for as_cpp (implement r-lib#432)
1 parent 05c888b commit fc83025

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

inst/include/cpp11/as.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,14 @@ template <typename T>
184184
enable_if_c_string<T, T> as_cpp(SEXP from) {
185185
if (Rf_isString(from)) {
186186
if (Rf_xlength(from) == 1) {
187-
// TODO: use vmaxget / vmaxset here?
188-
return {unwind_protect([&] { return Rf_translateCharUTF8(STRING_ELT(from, 0)); })};
187+
void* vmax = vmaxget();
188+
189+
const char* result =
190+
unwind_protect([&] { return Rf_translateCharUTF8(STRING_ELT(from, 0)); });
191+
192+
vmaxset(vmax);
193+
194+
return {result};
189195
}
190196
}
191197

0 commit comments

Comments
 (0)