summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2006-08-26 04:10:43 -0400
committerJunio C Hamano <junkio@cox.net>2006-08-26 17:35:15 -0700
commitde530aaa4b57b1edd9b973d814d7df8354752ccc (patch)
tree489044d36ea92c1135956c091d833a0eacd3966d /sha1_file.c
parenta7f051987c5f020e60da1e5d6ddefc3d443d3299 (diff)
downloadgit-de530aaa4b57b1edd9b973d814d7df8354752ccc.tar.gz
Reorganize/rename unpack_non_delta_entry to unpack_compressed_entry.
This function was moved above unpack_delta_entry so we can call it from within unpack_delta_entry without a forward declaration. This change looks worse than it is. Its really just a relocation of unpack_non_delta_entry to earlier in the file and renaming the function to unpack_compressed_entry. No other changes were made. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 769a80984d..53beb917dd 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1057,6 +1057,33 @@ static int packed_object_info(struct pack_entry *entry,
return 0;
}
+static void *unpack_compressed_entry(unsigned char *data,
+ unsigned long size,
+ unsigned long left)
+{
+ int st;
+ z_stream stream;
+ unsigned char *buffer;
+
+ buffer = xmalloc(size + 1);
+ buffer[size] = 0;
+ memset(&stream, 0, sizeof(stream));
+ stream.next_in = data;
+ stream.avail_in = left;
+ stream.next_out = buffer;
+ stream.avail_out = size;
+
+ inflateInit(&stream);
+ st = inflate(&stream, Z_FINISH);
+ inflateEnd(&stream);
+ if ((st != Z_STREAM_END) || stream.total_out != size) {
+ free(buffer);
+ return NULL;
+ }
+
+ return buffer;
+}
+
static void *unpack_delta_entry(unsigned char *base_sha1,
unsigned long delta_size,
unsigned long left,
@@ -1110,33 +1137,6 @@ static void *unpack_delta_entry(unsigned char *base_sha1,
return result;
}
-static void *unpack_non_delta_entry(unsigned char *data,
- unsigned long size,
- unsigned long left)
-{
- int st;
- z_stream stream;
- unsigned char *buffer;
-
- buffer = xmalloc(size + 1);
- buffer[size] = 0;
- memset(&stream, 0, sizeof(stream));
- stream.next_in = data;
- stream.avail_in = left;
- stream.next_out = buffer;
- stream.avail_out = size;
-
- inflateInit(&stream);
- st = inflate(&stream, Z_FINISH);
- inflateEnd(&stream);
- if ((st != Z_STREAM_END) || stream.total_out != size) {
- free(buffer);
- return NULL;
- }
-
- return buffer;
-}
-
static void *unpack_entry(struct pack_entry *entry,
char *type, unsigned long *sizep)
{
@@ -1185,7 +1185,7 @@ void *unpack_entry_gently(struct pack_entry *entry,
return NULL;
}
*sizep = size;
- retval = unpack_non_delta_entry(pack, size, left);
+ retval = unpack_compressed_entry(pack, size, left);
return retval;
}