Skip to content

Commit 21e343b

Browse files
authored
Merge pull request #37 from pachadotdev/vmaxgetset-clean
Vmaxgetset clean
2 parents 6739ade + fa90fd5 commit 21e343b

File tree

4 files changed

+1314
-1443
lines changed

4 files changed

+1314
-1443
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)