Skip to content

Commit 4cd643d

Browse files
author
luke
committed
Replace STRING_PTR by STRING_PTR_RO in a few places.
git-svn-id: https://svn.r-project.org/R/trunk@89004 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 231a17e commit 4cd643d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ attribute_hidden SEXP do_listfiles(SEXP call, SEXP op, SEXP args, SEXP rho)
16261626
search_cleanup(&pb);
16271627
REPROTECT(ans = lengthgets(ans, count), idx);
16281628
if (pattern) tre_regfree(&reg);
1629-
ssort(STRING_PTR(ans), count);
1629+
ssort(STRING_PTR(ans), count); /* STRING_PTR is safe here */
16301630
UNPROTECT(1);
16311631
return ans;
16321632
}
@@ -1722,7 +1722,7 @@ attribute_hidden SEXP do_listdirs(SEXP call, SEXP op, SEXP args, SEXP rho)
17221722
endcontext(&cntxt);
17231723
search_cleanup(&pb);
17241724
REPROTECT(ans = lengthgets(ans, count), idx);
1725-
ssort(STRING_PTR(ans), count);
1725+
ssort(STRING_PTR(ans), count); /* STRING_PTR is safe here */
17261726
UNPROTECT(1);
17271727
return ans;
17281728
}

src/main/sort.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ void sortVector(SEXP s, bool decreasing)
648648
R_csort2(COMPLEX(s), n, decreasing);
649649
break;
650650
case STRSXP:
651-
ssort2(STRING_PTR(s), n, decreasing);
651+
ssort2(STRING_PTR(s), n, decreasing); /* STRING_PTR is safe here */
652652
break;
653653
default:
654654
UNIMPLEMENTED_TYPE("sortVector", s);
@@ -747,7 +747,7 @@ static void Psort(SEXP x, R_xlen_t lo, R_xlen_t hi, R_xlen_t k)
747747
cPsort2(COMPLEX(x), lo, hi, k);
748748
break;
749749
case STRSXP:
750-
sPsort2(STRING_PTR(x), lo, hi, k);
750+
sPsort2(STRING_PTR(x), lo, hi, k); /* STRING_PTR is safe here */
751751
break;
752752
default:
753753
UNIMPLEMENTED_TYPE("Psort", x);
@@ -1156,7 +1156,7 @@ orderVector1(int *indx, int n, SEXP key, bool nalast, bool decreasing, SEXP rho)
11561156
int *ix = NULL /* -Wall */;
11571157
double *x = NULL /* -Wall */;
11581158
Rcomplex *cx = NULL /* -Wall */;
1159-
SEXP *sx = NULL /* -Wall */;
1159+
const SEXP *sx = NULL /* -Wall */;
11601160

11611161
if (n < 2) return;
11621162
switch (TYPEOF(key)) {
@@ -1168,7 +1168,7 @@ orderVector1(int *indx, int n, SEXP key, bool nalast, bool decreasing, SEXP rho)
11681168
x = REAL(key);
11691169
break;
11701170
case STRSXP:
1171-
sx = STRING_PTR(key);
1171+
sx = STRING_PTR_RO(key);
11721172
break;
11731173
case CPLXSXP:
11741174
cx = COMPLEX(key);
@@ -1292,7 +1292,7 @@ orderVector1l(R_xlen_t *indx, R_xlen_t n, SEXP key, bool nalast,
12921292
int *ix = NULL /* -Wall */;
12931293
double *x = NULL /* -Wall */;
12941294
Rcomplex *cx = NULL /* -Wall */;
1295-
SEXP *sx = NULL /* -Wall */;
1295+
const SEXP *sx = NULL /* -Wall */;
12961296
R_xlen_t itmp;
12971297

12981298
if (n < 2) return;
@@ -1305,7 +1305,7 @@ orderVector1l(R_xlen_t *indx, R_xlen_t n, SEXP key, bool nalast,
13051305
x = REAL(key);
13061306
break;
13071307
case STRSXP:
1308-
sx = STRING_PTR(key);
1308+
sx = STRING_PTR_RO(key);
13091309
break;
13101310
case CPLXSXP:
13111311
cx = COMPLEX(key);

0 commit comments

Comments
 (0)