Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove erroneous PreserveObject call in String::wrap #1082

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2020-05-17 Kevin Ushey <kevinushey@gmail.com>

* inst/include/Rcpp/String.h: don't preserve returned SEXP in wrap
* inst/include/RcppCommon.h: simplify

2020-04-30 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor version
Expand Down
1 change: 0 additions & 1 deletion inst/include/Rcpp/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ namespace Rcpp {
RCPP_STRING_DEBUG("wrap<String>()");
Shield<SEXP> res(Rf_allocVector(STRSXP, 1));
SEXP data = object.get_sexp();
Rcpp_PreserveObject(data);
SET_STRING_ELT(res, 0, data);
return res;
}
Expand Down
19 changes: 5 additions & 14 deletions inst/include/RcppCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,13 @@ namespace Rcpp {
}

inline SEXP Rcpp_ReplaceObject(SEXP x, SEXP y) {
if (Rf_isNull(x)) {
Rcpp_PreserveObject(y);
} else if (Rf_isNull(y)) {
Rcpp_ReleaseObject(x); // #nocov
} else {
// if we are setting to the same SEXP as we already have, do nothing
if (x != y) {

// the previous SEXP was not NULL, so release it
Rcpp_ReleaseObject(x);

// the new SEXP is not NULL, so preserve it
Rcpp_PreserveObject(y);

}
// if we are setting to the same SEXP as we already have, do nothing
if (x != y) {
Rcpp_ReleaseObject(x);
Rcpp_PreserveObject(y);
}

return y;
}

Expand Down