summaryrefslogtreecommitdiff
path: root/delta.h
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 /delta.h
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 'delta.h')
-rw-r--r--delta.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/delta.h b/delta.h
index bc3a220179..31d1820f80 100644
--- a/delta.h
+++ b/delta.h
@@ -9,4 +9,26 @@ extern void *patch_delta(void *src_buf, unsigned long src_size,
void *delta_buf, unsigned long delta_size,
unsigned long *dst_size);
+/* the smallest possible delta size is 4 bytes */
+#define DELTA_SIZE_MIN 4
+
+/*
+ * This must be called twice on the delta data buffer, first to get the
+ * expected reference buffer size, and again to get the result buffer size.
+ */
+static inline unsigned long get_delta_hdr_size(const unsigned char **datap)
+{
+ const unsigned char *data = *datap;
+ unsigned char cmd = *data++;
+ unsigned long size = cmd & ~0x80;
+ int i = 7;
+ while (cmd & 0x80) {
+ cmd = *data++;
+ size |= (cmd & ~0x80) << i;
+ i += 7;
+ }
+ *datap = data;
+ return size;
+}
+
#endif