summaryrefslogtreecommitdiff
path: root/patch-delta.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2005-06-29 02:49:56 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-29 09:11:38 -0700
commitdcde55bc58ae845307efbdce3a1071f75ccd758e (patch)
treefc76dbd773c225cef239a0774304335c8116f2bc /patch-delta.c
parente5e3e0f5001f51fe388d530481e56651729add1a (diff)
downloadgit-dcde55bc58ae845307efbdce3a1071f75ccd758e.tar.gz
[PATCH] assorted delta code cleanup
This is a wrap-up patch including all the cleanups I've done to the delta code and its usage. The most important change is the factorization of the delta header handling code. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'patch-delta.c')
-rw-r--r--patch-delta.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/patch-delta.c b/patch-delta.c
index b68dd13c63..26281ea123 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -20,36 +20,20 @@ void *patch_delta(void *src_buf, unsigned long src_size,
const unsigned char *data, *top;
unsigned char *dst_buf, *out, cmd;
unsigned long size;
- int i;
- /* the smallest delta size possible is 4 bytes */
- if (delta_size < 4)
+ if (delta_size < DELTA_SIZE_MIN)
return NULL;
data = delta_buf;
top = delta_buf + delta_size;
/* make sure the orig file size matches what we expect */
- cmd = *data++;
- size = cmd & ~0x80;
- i = 7;
- while (cmd & 0x80) {
- cmd = *data++;
- size |= (cmd & ~0x80) << i;
- i += 7;
- }
+ size = get_delta_hdr_size(&data);
if (size != src_size)
return NULL;
/* now the result size */
- cmd = *data++;
- size = cmd & ~0x80;
- i = 7;
- while (cmd & 0x80) {
- cmd = *data++;
- size |= (cmd & ~0x80) << i;
- i += 7;
- }
+ size = get_delta_hdr_size(&data);
dst_buf = malloc(size);
if (!dst_buf)
return NULL;