diff --git a/py/obj.h b/py/obj.h index 7bf00d4dee..9028c06121 100644 --- a/py/obj.h +++ b/py/obj.h @@ -585,8 +585,8 @@ mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *i #define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_t) \ /*printf("memcpy(%p, %p, %d)\n", dest + beg, slice, slice_len * sizeof(item_t));*/ \ memcpy(dest + beg, slice, slice_len * sizeof(item_t)); \ - /*printf("memcpy(%p, %p, %d)\n", dest + (beg + slice_len), dest + end, (dest_len - end) * sizeof(item_t));*/ \ - memcpy(dest + (beg + slice_len), dest + end, (dest_len - end) * sizeof(item_t)); + /*printf("memmove(%p, %p, %d)\n", dest + (beg + slice_len), dest + end, (dest_len - end) * sizeof(item_t));*/ \ + memmove(dest + (beg + slice_len), dest + end, (dest_len - end) * sizeof(item_t)); #define mp_seq_replace_slice_grow_inplace(dest, dest_len, beg, end, slice, slice_len, len_adj, item_t) \ /*printf("memmove(%p, %p, %d)\n", dest + beg + len_adj, dest + beg, (dest_len - beg) * sizeof(item_t));*/ \ diff --git a/py/objlist.c b/py/objlist.c index 578e39452a..e459f0deb1 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -274,7 +274,7 @@ STATIC mp_obj_t list_pop(uint n_args, const mp_obj_t *args) { uint index = mp_get_index(self->base.type, self->len, n_args == 1 ? MP_OBJ_NEW_SMALL_INT(-1) : args[1], false); mp_obj_t ret = self->items[index]; self->len -= 1; - memcpy(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t)); + memmove(self->items + index, self->items + index + 1, (self->len - index) * sizeof(mp_obj_t)); // Clear stale pointer from slot which just got freed to prevent GC issues self->items[self->len] = MP_OBJ_NULL; if (self->alloc > LIST_MIN_ALLOC && self->alloc > 2 * self->len) { diff --git a/py/objstr.c b/py/objstr.c index 366ba88163..fd4bc8289f 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -567,7 +567,7 @@ STATIC mp_obj_t str_rsplit(uint n_args, const mp_obj_t *args) { if (idx != 0) { // We split less parts than split limit, now go cleanup surplus int used = org_splits + 1 - idx; - memcpy(res->items, &res->items[idx], used * sizeof(mp_obj_t)); + memmove(res->items, &res->items[idx], used * sizeof(mp_obj_t)); mp_seq_clear(res->items, used, res->alloc, sizeof(*res->items)); res->len = used; }