Skip to content

Commit

Permalink
Replace allocList/SET_TYPEOF idiom with allocLang.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@86618 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
luke committed May 25, 2024
1 parent 6f5e633 commit 8e74f3a
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/library/stats/src/deriv.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ static SEXP D(SEXP expr, SEXP var)
UNPROTECT(4);
}
else if (CAR(expr) == SqrtSymbol) {
PROTECT(expr1 = allocList(3));
SET_TYPEOF(expr1, LANGSXP);
PROTECT(expr1 = allocLang(3));
SETCAR(expr1, PowerSymbol);
SETCADR(expr1, CADR(expr));
SETCADDR(expr1, Constant(0.5));
Expand Down
3 changes: 1 addition & 2 deletions src/library/stats/src/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ SEXP modelmatrix(SEXP call, SEXP op, SEXP args, SEXP rho)
PROTECT(contr1 = allocVector(VECSXP, nVar));
PROTECT(contr2 = allocVector(VECSXP, nVar));

PROTECT(expr = allocList(3));
SET_TYPEOF(expr, LANGSXP);
PROTECT(expr = allocLang(3));
SETCAR(expr, install("contrasts"));
SETCADDR(expr, allocVector(LGLSXP, 1));

Expand Down
3 changes: 1 addition & 2 deletions src/main/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,7 @@ attribute_hidden SEXP do_namesgets(SEXP call, SEXP op, SEXP args, SEXP env)
SEXP names = CADR(args);
if (names != R_NilValue &&
! (TYPEOF(names) == STRSXP && ATTRIB(names) == R_NilValue)) {
PROTECT(call = allocList(2));
SET_TYPEOF(call, LANGSXP);
PROTECT(call = allocLang(2));
SETCAR(call, R_AsCharacterSymbol);
SETCADR(call, names);
names = eval(call, env);
Expand Down
3 changes: 1 addition & 2 deletions src/main/coerce.c
Original file line number Diff line number Diff line change
Expand Up @@ -2737,8 +2737,7 @@ attribute_hidden SEXP do_docall(SEXP call, SEXP op, SEXP args, SEXP rho)
n = length(args);
PROTECT(names = getAttrib(args, R_NamesSymbol));

PROTECT(c = call = allocList(n + 1));
SET_TYPEOF(c, LANGSXP);
PROTECT(c = call = allocLang(n + 1));
if( isString(fun) ) {
const char *str = translateChar(STRING_ELT(fun, 0));
if (streql(str, ".Internal")) error("illegal usage");
Expand Down
3 changes: 1 addition & 2 deletions src/main/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ static SEXP replaceCall(SEXP fun, SEXP val, SEXP args, SEXP rhs)
PROTECT(args);
PROTECT(rhs);
PROTECT(val);
ptmp = tmp = allocList(length(args)+3);
ptmp = tmp = allocLang(length(args)+3);
UNPROTECT(4);
SETCAR(ptmp, fun); ptmp = CDR(ptmp);
SETCAR(ptmp, val); ptmp = CDR(ptmp);
Expand All @@ -2641,7 +2641,6 @@ static SEXP replaceCall(SEXP fun, SEXP val, SEXP args, SEXP rhs)
}
SETCAR(ptmp, rhs);
SET_TAG(ptmp, R_valueSym);
SET_TYPEOF(tmp, LANGSXP);
MARK_ASSIGNMENT_CALL(tmp);
return tmp;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ static SEXP FindTaggedItem(SEXP lst, SEXP tag)
static SEXP makeErrorCall(SEXP fun)
{
SEXP call;
PROTECT(call = allocList(1));
SET_TYPEOF(call, LANGSXP);
PROTECT(call = allocLang(1));
SETCAR(call, fun);
UNPROTECT(1);
return call;
Expand Down
3 changes: 1 addition & 2 deletions src/main/subset.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,8 @@ attribute_hidden SEXP do_subset_dflt(SEXP call, SEXP op, SEXP args, SEXP rho)

if (type == LANGSXP) {
ax = ans;
PROTECT(ans = allocList(LENGTH(ax)));
PROTECT(ans = allocLang(LENGTH(ax)));
if ( LENGTH(ax) > 0 ) {
SET_TYPEOF(ans, LANGSXP);
SEXP px; int i;
for(px = ans, i = 0 ; px != R_NilValue ; px = CDR(px))
SETCAR(px, VECTOR_ELT(ax, i++));
Expand Down

0 comments on commit 8e74f3a

Please sign in to comment.