Skip to content

Commit

Permalink
Use memmove instead of memcpy for overlapping areas
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Edgar Toernig authored and Junio C Hamano committed Oct 31, 2006
1 parent 6dcfa30 commit 79a6569
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions builtin-unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ static SHA_CTX ctx;
* Make sure at least "min" bytes are available in the buffer, and
* return the pointer to the buffer.
*/
static void * fill(int min)
static void *fill(int min)
{
if (min <= len)
return buffer + offset;
if (min > sizeof(buffer))
die("cannot fill %d bytes", min);
if (offset) {
SHA1_Update(&ctx, buffer, offset);
memcpy(buffer, buffer + offset, len);
memmove(buffer, buffer + offset, len);
offset = 0;
}
do {
Expand Down
4 changes: 2 additions & 2 deletions index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ static int input_fd;
* Make sure at least "min" bytes are available in the buffer, and
* return the pointer to the buffer.
*/
static void * fill(int min)
static void *fill(int min)
{
if (min <= input_len)
return input_buffer + input_offset;
if (min > sizeof(input_buffer))
die("cannot fill %d bytes", min);
if (input_offset) {
SHA1_Update(&input_ctx, input_buffer, input_offset);
memcpy(input_buffer, input_buffer + input_offset, input_len);
memmove(input_buffer, input_buffer + input_offset, input_len);
input_offset = 0;
}
do {
Expand Down

0 comments on commit 79a6569

Please sign in to comment.