ref: f491d023bf5d6907e2e4cec32c17fb702d258a4e
parent: f09637f62c7e948abb5c0e5df7d1b770de9625e6
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Mar 27 09:40:53 EDT 2023
memcpy -> memmove
--- a/cvalues.c
+++ b/cvalues.c
@@ -170,7 +170,7 @@
{
value_t cv;
cv = cvalue(type, sz);
- memcpy(cptr(cv), data, sz);
+ memmove(cptr(cv), data, sz);
return cv;
}
@@ -212,7 +212,7 @@
value_t string_from_cstrn(char *str, size_t n)
{
value_t v = cvalue_string(n);
- memcpy(cvalue_data(v), str, n);
+ memmove(cvalue_data(v), str, n);
return v;
}
@@ -234,7 +234,7 @@
size_t sz = cv_len(cv);
if (cv_isstr(cv)) sz++;
void *data = malloc(sz);
- memcpy(data, cv_data(cv), sz);
+ memmove(data, cv_data(cv), sz);
cv->data = data;
autorelease(cv);
}
@@ -438,7 +438,7 @@
fltype_t *aet = cv_class(cv)->eltype;
if (aet == eltype) {
if (cv_len(cv) == sz)
- memcpy(dest, cv_data(cv), sz);
+ memmove(dest, cv_data(cv), sz);
else
lerrorf(ArgError, "array: size mismatch");
return 0;
@@ -638,7 +638,7 @@
nw = cv_nwords(cv);
nv = (cvalue_t*)alloc_words(nw);
- memcpy(nv, cv, nw*sizeof(value_t));
+ memmove(nv, cv, nw*sizeof(value_t));
if (isinlined(cv))
nv->data = &nv->_space[0];
ncv = tagptr(nv, TAG_CVALUE);
@@ -657,12 +657,12 @@
size_t nw = cv_nwords(cv);
cvalue_t *ncv = (cvalue_t*)alloc_words(nw);
v = POP(); cv = (cvalue_t*)ptr(v);
- memcpy(ncv, cv, nw * sizeof(value_t));
+ memmove(ncv, cv, nw * sizeof(value_t));
if (!isinlined(cv)) {
size_t len = cv_len(cv);
if (cv_isstr(cv)) len++;
ncv->data = malloc(len);
- memcpy(ncv->data, cv_data(cv), len);
+ memmove(ncv->data, cv_data(cv), len);
autorelease(ncv);
if (hasparent(cv)) {
ncv->type = (fltype_t*)(((uintptr_t)ncv->type) & ~CV_PARENT_BIT);
@@ -801,7 +801,7 @@
else if (sz == 8)
*(int64_t*)dest = ((int64_t*)data)[index];
else
- memcpy(dest, data + index*sz, sz);
+ memmove(dest, data + index*sz, sz);
return el;
}
--- a/flisp.c
+++ b/flisp.c
@@ -203,7 +203,7 @@
sym->binding = UNBOUND;
}
sym->hash = memhash32(str, len)^0xAAAAAAAA;
- memcpy(sym->name, str, len+1);
+ memmove(sym->name, str, len+1);
return sym;
}
@@ -824,7 +824,7 @@
nargs = ntot + nrestargs;
if (nrestargs)
memmove(&Stack[bp+ntot], &Stack[bp+i], nrestargs*sizeof(value_t));
- memcpy(&Stack[bp+nreq], args, extr*sizeof(value_t));
+ memmove(&Stack[bp+nreq], args, extr*sizeof(value_t));
SP = bp + nargs;
assert(SP < N_STACK-5);
PUSH(s5);
@@ -1556,7 +1556,7 @@
apply_vector:
v = alloc_vector(n, 0);
if (n) {
- memcpy(&vector_elt(v,0), &Stack[SP-n], n*sizeof(value_t));
+ memmove(&vector_elt(v,0), &Stack[SP-n], n*sizeof(value_t));
POPN(n);
}
PUSH(v);
@@ -1795,7 +1795,7 @@
v = alloc_vector(sz, 0);
if (Stack[top-1] /*captured*/) {
vector_elt(v, 0) = Stack[bp];
- memcpy(&vector_elt(v, 1),
+ memmove(&vector_elt(v, 1),
&vector_elt(Stack[bp+1],0), (sz-1)*sizeof(value_t));
}
else {
--- a/iostream.c
+++ b/iostream.c
@@ -381,7 +381,7 @@
if (st->buf == &st->local[0]) {
n = st->size;
str = cvalue_string(n);
- memcpy(cvalue_data(str), value2c(ios_t*,*ps)->buf, n);
+ memmove(cvalue_data(str), value2c(ios_t*,*ps)->buf, n);
ios_trunc(value2c(ios_t*,*ps), 0);
}
else {
--- a/llt/bitvector-ops.c
+++ b/llt/bitvector-ops.c
@@ -62,7 +62,7 @@
uint32_t i, j;
if (n == 0) return;
if (s == 0) {
- memcpy(dest, b, n*4);
+ memmove(dest, b, n*4);
return;
}
j = (s>>5);
@@ -105,7 +105,7 @@
uint32_t i, j, sc=0;
if (n == 0) return;
if (s == 0) {
- memcpy(dest, b, n*4);
+ memmove(dest, b, n*4);
return;
}
j = (s>>5);
--- a/llt/ios.c
+++ b/llt/ios.c
@@ -137,7 +137,7 @@
return NULL;
s->ownbuf = 1;
if (s->size > 0)
- memcpy(temp, s->buf, s->size);
+ memmove(temp, s->buf, s->size);
}
s->buf = temp;
@@ -166,7 +166,7 @@
/* no more space; write as much as we can */
amt = s->maxsize - s->bpos;
if (amt > 0) {
- memcpy(&s->buf[s->bpos], data, amt);
+ memmove(&s->buf[s->bpos], data, amt);
}
s->bpos += amt;
s->size = s->maxsize;
@@ -175,7 +175,7 @@
}
s->size = s->bpos + n;
}
- memcpy(s->buf + s->bpos, data, n);
+ memmove(s->buf + s->bpos, data, n);
s->bpos += n;
return n;
@@ -194,7 +194,7 @@
if (avail > 0) {
size_t ncopy = (avail >= n) ? n : avail;
- memcpy(dest, s->buf + s->bpos, ncopy);
+ memmove(dest, s->buf + s->bpos, ncopy);
s->bpos += ncopy;
if (ncopy >= n) {
s->state = bst_rd;
@@ -333,7 +333,7 @@
data += linesz;
}
}
- memcpy(s->buf + s->bpos, data, n);
+ memmove(s->buf + s->bpos, data, n);
s->bpos += n;
wrote += n;
}
@@ -554,7 +554,7 @@
if (buf == NULL)
return NULL;
if (s->size)
- memcpy(buf, s->buf, s->size);
+ memmove(buf, s->buf, s->size);
}
else {
buf = s->buf;
@@ -576,7 +576,7 @@
nvalid = (size < s->size) ? size : s->size;
if (nvalid > 0)
- memcpy(buf, s->buf, nvalid);
+ memmove(buf, s->buf, nvalid);
if (s->bpos > nvalid) {
// truncated
s->bpos = nvalid;
--- a/llt/lltinit.c
+++ b/llt/lltinit.c
@@ -21,10 +21,10 @@
D_NINF = strtod("-Inf",NULL);
#if defined(__plan9__)
u32int x;
- x = 0x7fc00000; memcpy(&F_PNAN, &x, 4);
- x = 0xffc00000; memcpy(&F_NNAN, &x, 4);
- x = 0x7f800000; memcpy(&F_PINF, &x, 4);
- x = 0xff800000; memcpy(&F_NINF, &x, 4);
+ x = 0x7fc00000; memmove(&F_PNAN, &x, 4);
+ x = 0xffc00000; memmove(&F_NNAN, &x, 4);
+ x = 0x7f800000; memmove(&F_PINF, &x, 4);
+ x = 0xff800000; memmove(&F_NINF, &x, 4);
#else
F_PNAN = strtof("+NaN",NULL);
F_NNAN = -strtof("+NaN",NULL);
--- a/llt/utf8.c
+++ b/llt/utf8.c
@@ -400,7 +400,7 @@
amt = u8_wc_toutf8(temp, ch);
if (amt > sz-c)
break;
- memcpy(&buf[c], temp, amt);
+ memmove(&buf[c], temp, amt);
c += amt;
}
if (c < sz)
--- a/read.c
+++ b/read.c
@@ -552,7 +552,7 @@
}
}
s = cvalue_string(i);
- memcpy(cvalue_data(s), buf, i);
+ memmove(cvalue_data(s), buf, i);
free(buf);
return s;
}
--- a/string.c
+++ b/string.c
@@ -159,7 +159,7 @@
s = cv_data((cvalue_t*)ptr(args[0]));
delim = cv_data((cvalue_t*)ptr(args[1]));
- if (ssz) memcpy(cv_data((cvalue_t*)ptr(car_(c))), &s[tokstart], ssz);
+ if (ssz) memmove(cv_data((cvalue_t*)ptr(car_(c))), &s[tokstart], ssz);
// link new cell
if (last == FL_NIL)
@@ -196,7 +196,7 @@
if (i2 <= i1)
return cvalue_string(0);
value_t ns = cvalue_string(i2-i1);
- memcpy(cv_data((cvalue_t*)ptr(ns)), &s[i1], i2-i1);
+ memmove(cv_data((cvalue_t*)ptr(ns)), &s[i1], i2-i1);
return ns;
}