From: Edgar Toernig Date: Tue, 31 Oct 2006 01:44:27 +0000 (-0800) Subject: Use memmove instead of memcpy for overlapping areas X-Git-Tag: v1.4.4-rc1~48 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=79a65697be00f3b53430930078a7d34b591d5070;p=git.git Use memmove instead of memcpy for overlapping areas Signed-off-by: Junio C Hamano --- diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index e70a71163..74a90c112 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -22,7 +22,7 @@ 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; @@ -30,7 +30,7 @@ static void * fill(int min) 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 { diff --git a/index-pack.c b/index-pack.c index e33f60524..70640e14d 100644 --- a/index-pack.c +++ b/index-pack.c @@ -53,7 +53,7 @@ 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; @@ -61,7 +61,7 @@ static void * fill(int min) 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 {