Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions inst/include/cpp11/as.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,14 @@ template <typename Container, typename AsCstring>
SEXP as_sexp_strings(const Container& from, AsCstring&& c_str) {
R_xlen_t size = from.size();

SEXP data;
try {
data = PROTECT(safe[Rf_allocVector](STRSXP, size));
SEXP data = PROTECT(safe[Rf_allocVector](STRSXP, size));

unwind_protect([&] {
auto it = from.begin();
for (R_xlen_t i = 0; i < size; ++i, ++it) {
SET_STRING_ELT(data, i, safe[Rf_mkCharCE](c_str(*it), CE_UTF8));
SET_STRING_ELT(data, i, Rf_mkCharCE(c_str(*it), CE_UTF8));
}
} catch (const unwind_exception& e) {
UNPROTECT(1);
throw e;
}
});

UNPROTECT(1);
return data;
Expand Down