Skip to content

Commit c42a61e

Browse files
authored
Merge pull request #26 from pachadotdev/vmaxgetset-clean
Vmaxgetset clean
2 parents 015c9e6 + fa90fd5 commit c42a61e

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
@@ -187,8 +187,14 @@ template <typename T>
187187
enable_if_c_string<T, T> as_cpp(SEXP from) {
188188
if (Rf_isString(from)) {
189189
if (Rf_xlength(from) == 1) {
190-
// TODO: use vmaxget / vmaxset here?
191-
return {unwind_protect([&] { return Rf_translateCharUTF8(STRING_ELT(from, 0)); })};
190+
void* vmax = vmaxget();
191+
192+
const char* result =
193+
unwind_protect([&] { return Rf_translateCharUTF8(STRING_ELT(from, 0)); });
194+
195+
vmaxset(vmax);
196+
197+
return {result};
192198
}
193199
}
194200

0 commit comments

Comments
 (0)