From cca2c832d0ae12a494564acb35922796dcc901ea Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 23 Jul 2014 13:33:06 -0400 Subject: [PATCH] Switch from memcpy to memmove for vector --- .gitignore | 2 ++ source/vector/vec.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 182c88f..83d69fe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ tags project.vim Makefile build/ +*.o +.rsconscache diff --git a/source/vector/vec.c b/source/vector/vec.c index 5c1decf..0bf3e5a 100644 --- a/source/vector/vec.c +++ b/source/vector/vec.c @@ -133,9 +133,9 @@ bool vec_insert(vec_t* p_vec, size_t index, size_t num_elements, ...) /* Resize the vector to fit the new contents */ vec_resize( p_vec, p_vec->size + num_elements, NULL ); /* Move the displaced items to the end */ - memcpy( &(p_vec->p_buffer[index + num_elements]), - &(p_vec->p_buffer[index]), - sizeof(void*) * (p_vec->size - index)); + memmove(&(p_vec->p_buffer[index + num_elements]), + &(p_vec->p_buffer[index]), + sizeof(void*) * (p_vec->size - index)); /* insert the new items */ va_start(elements, num_elements); new_size = index + num_elements; @@ -158,7 +158,7 @@ bool vec_erase(vec_t* p_vec, size_t start_idx, size_t end_idx) /* Free the range of data */ vec_free_range(p_vec->p_buffer, start_idx, end_idx + 1); /* Compact the remaining data */ - memcpy( &(p_vec->p_buffer[start_idx]), /* Destination is beginning of erased range */ + memmove(&(p_vec->p_buffer[start_idx]), /* Destination is beginning of erased range */ &(p_vec->p_buffer[end_idx+1]), /* Source is end of erased range */ sizeof(void*) * (p_vec->size - end_idx - 1)); /* Shrink the size */ -- 2.52.0