shithub: femtolisp

Download patch

ref: b215b13501aa7fa867877122fe5c24ba45b3bbba
parent: 0f3c051904ead079fa2f2457d86623283e5f2ecb
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Nov 12 22:29:55 EST 2024

memmove → memcpy where applicable

--- a/cvalues.c
+++ b/cvalues.c
@@ -140,7 +140,7 @@
 {
 	value_t cv;
 	cv = cvalue(type, sz);
-	memmove(cptr(cv), data, sz);
+	memcpy(cptr(cv), data, sz);
 	return cv;
 }
 
@@ -186,7 +186,7 @@
 string_from_cstrn(char *str, size_t n)
 {
 	value_t v = cvalue_string(n);
-	memmove(cvalue_data(v), str, n);
+	memcpy(cvalue_data(v), str, n);
 	return v;
 }
 
@@ -212,7 +212,7 @@
 	if(cv_isstr(cv))
 		sz++;
 	void *data = LLT_ALLOC(sz);
-	memmove(data, cv_data(cv), sz);
+	memcpy(data, cv_data(cv), sz);
 	cv->data = data;
 	autorelease(cv);
 }
@@ -488,7 +488,7 @@
 			fltype_t *aet = cv_class(cv)->eltype;
 			if(aet == eltype){
 				if(cv_len(cv) == sz)
-					memmove(dest, cv_data(cv), sz);
+					memcpy(dest, cv_data(cv), sz);
 				else
 					lerrorf(FL(ArgError), "size mismatch");
 				return 0;
@@ -713,7 +713,7 @@
 
 	nw = cv_nwords(cv);
 	nv = alloc_words(nw);
-	memmove(nv, cv, nw*sizeof(value_t));
+	memcpy(nv, cv, nw*sizeof(value_t));
 	if(isinlined(cv))
 		nv->data = &nv->_space[0];
 	ncv = tagptr(nv, TAG_CVALUE);
@@ -736,13 +736,13 @@
 	cvalue_t *ncv = alloc_words(nw);
 	v = POP();
 	cv = ptr(v);
-	memmove(ncv, cv, nw * sizeof(value_t));
+	memcpy(ncv, cv, nw * sizeof(value_t));
 	if(!isinlined(cv)){
 		size_t len = cv_len(cv);
 		if(cv_isstr(cv))
 			len++;
 		ncv->data = LLT_ALLOC(len);
-		memmove(ncv->data, cv_data(cv), len);
+		memcpy(ncv->data, cv_data(cv), len);
 		autorelease(ncv);
 		if(hasparent(cv)){
 			ncv->type = (fltype_t*)(((uintptr_t)ncv->type) & ~CV_PARENT_BIT);
@@ -880,7 +880,7 @@
 	else if(sz == 8)
 		*(int64_t*)dest = ((int64_t*)data)[index];
 	else
-		memmove(dest, data + index*sz, sz);
+		memcpy(dest, data + index*sz, sz);
 	return el;
 }
 
--- a/flisp.c
+++ b/flisp.c
@@ -184,7 +184,7 @@
 		sym->binding = UNBOUND;
 	}
 	sym->hash = memhash32(str, len)^0xAAAAAAAA;
-	memmove(sym->name, str, len+1);
+	memcpy(sym->name, str, len+1);
 	return sym;
 }
 
@@ -1633,7 +1633,7 @@
 		apply_vector:
 			v = alloc_vector(n, 0);
 			if(n){
-				memmove(&vector_elt(v, 0), &FL(stack)[FL(sp)-n], n*sizeof(value_t));
+				memcpy(&vector_elt(v, 0), &FL(stack)[FL(sp)-n], n*sizeof(value_t));
 				POPN(n);
 			}
 			PUSH(v);
--- a/ios.c
+++ b/ios.c
@@ -149,7 +149,7 @@
 			return nil;
 		s->ownbuf = 1;
 		if(s->size > 0)
-			memmove(temp, s->buf, s->size);
+			memcpy(temp, s->buf, s->size);
 	}
 
 	s->buf = temp;
@@ -179,7 +179,7 @@
 				/* no more space; write as much as we can */
 				amt = s->maxsize - s->bpos;
 				if(amt > 0)
-					memmove(&s->buf[s->bpos], data, amt);
+					memcpy(&s->buf[s->bpos], data, amt);
 				s->bpos += amt;
 				s->size = s->maxsize;
 				return amt;
@@ -187,7 +187,7 @@
 		}
 		s->size = s->bpos + n;
 	}
-	memmove(s->buf + s->bpos, data, n);
+	memcpy(s->buf + s->bpos, data, n);
 	s->bpos += n;
 
 	return n;
@@ -207,7 +207,7 @@
 
 		if(avail > 0){
 			size_t ncopy = avail >= n ? n : avail;
-			memmove(dest, s->buf + s->bpos, ncopy);
+			memcpy(dest, s->buf + s->bpos, ncopy);
 			s->bpos += ncopy;
 			if(ncopy >= n){
 				s->state = bst_rd;
@@ -346,7 +346,7 @@
 				data = (char*)data + linesz;
 			}
 		}
-		memmove(s->buf + s->bpos, data, n);
+		memcpy(s->buf + s->bpos, data, n);
 		s->bpos += n;
 		wrote += n;
 	}else{
@@ -568,7 +568,7 @@
 		if(buf == nil)
 			return nil;
 		if(s->size)
-			memmove(buf, s->buf, s->size);
+			memcpy(buf, s->buf, s->size);
 	}else if(s->size == s->maxsize){
 		buf = LLT_REALLOC(s->buf, s->size + 1);
 		if(buf == nil)
@@ -593,7 +593,7 @@
 
 	nvalid = size < s->size ? size : s->size;
 	if(nvalid > 0)
-		memmove(buf, s->buf, nvalid);
+		memcpy(buf, s->buf, nvalid);
 	if(s->bpos > nvalid){
 		// truncated
 		s->bpos = nvalid;
--- a/iostream.c
+++ b/iostream.c
@@ -417,7 +417,7 @@
 	if(st->buf == &st->local[0]){
 		n = st->size;
 		str = cvalue_string(n);
-		memmove(cvalue_data(str), st->buf, n);
+		memcpy(cvalue_data(str), st->buf, n);
 		ios_trunc(st, 0);
 	}else{
 		uint8_t *b = ios_takebuf(st, &n); n--;
--- a/read.c
+++ b/read.c
@@ -583,7 +583,7 @@
 		}
 	}
 	s = cvalue_string(i);
-	memmove(cvalue_data(s), buf, i);
+	memcpy(cvalue_data(s), buf, i);
 	LLT_FREE(buf);
 	return s;
 }