Skip to content

Commit 479d4a1

Browse files
committed
Merge pull request #12 from pachadotdev/vmaxgetset
implement r-lib#432
1 parent c98670f commit 479d4a1

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)