@matheusbsbs / matheus-bagliano / commits / 79a65697be
Fork 0

Use memmove instead of memcpy for overlapping areas

Signed-off-by: Junio C Hamano <junkio@cox.net>

Edgar Toernig committed Oct 30, 2006 at 17:44 UTC 79a65697be00f3b53430930078a7d34b591d5070
2 files changed +4 -4
builtin-unpack-objects.c
+2 -2
@@ -22,7 +22,7 @@ static SHA_CTX ctx;
22 * Make sure at least "min" bytes are available in the buffer, and
23 * return the pointer to the buffer.
24 */
25 -static void * fill(int min)
25 +static void *fill(int min)
26 {
27 if (min <= len)
28 return buffer + offset;
@@ -30,7 +30,7 @@ static void * fill(int min)
30 die("cannot fill %d bytes", min);
31 if (offset) {
32 SHA1_Update(&ctx, buffer, offset);
33 - memcpy(buffer, buffer + offset, len);
33 + memmove(buffer, buffer + offset, len);
34 offset = 0;
35 }
36 do {
index-pack.c
+2 -2
@@ -53,7 +53,7 @@ static int input_fd;
53 * Make sure at least "min" bytes are available in the buffer, and
54 * return the pointer to the buffer.
55 */
56 -static void * fill(int min)
56 +static void *fill(int min)
57 {
58 if (min <= input_len)
59 return input_buffer + input_offset;
@@ -61,7 +61,7 @@ static void * fill(int min)
61 die("cannot fill %d bytes", min);
62 if (input_offset) {
63 SHA1_Update(&input_ctx, input_buffer, input_offset);
64 - memcpy(input_buffer, input_buffer + input_offset, input_len);
64 + memmove(input_buffer, input_buffer + input_offset, input_len);
65 input_offset = 0;
66 }
67 do {