{"thread":{"id":"5392","subject":"[PATCH 4/5] Cleanup unpack_object_header to use only offsets.","startedAt":"2006-08-26T08:12:04Z","lastAt":"2006-08-26T08:12:04Z","messageCount":1,"participants":["Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"25928","messageId":"20060826081204.GF22343@spearce.org","threadId":"5392","inReplyTo":null,"subject":"[PATCH 4/5] Cleanup unpack_object_header to use only offsets.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-08-26T08:12:04Z","receivedAt":"2006-08-26T08:12:04Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If we're always incrementing both the offset and the pointer we\naren't gaining anything by keeping both.  Instead just use the\noffset since that's what we were given and what we are expected\nto return.  Also using offset is likely to make it easier to remap\nthe pack in the future should partial mapping of very large packs\nget implemented.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n sha1_file.c |   10 +++-------\n 1 files changed, 3 insertions(+), 7 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex b580cee..e6d47c1 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -917,23 +917,19 @@ static unsigned long unpack_object_heade\n \tenum object_type *type, unsigned long *sizep)\n {\n \tunsigned shift;\n-\tunsigned char *pack, c;\n+\tunsigned char c;\n \tunsigned long size;\n \n \tif (offset >= p->pack_size)\n \t\tdie(\"object offset outside of pack file\");\n-\n-\tpack =  (unsigned char *) p->pack_base + offset;\n-\tc = *pack++;\n-\toffset++;\n+\tc = *((unsigned char *)p->pack_base + offset++);\n \t*type = (c >> 4) & 7;\n \tsize = c & 15;\n \tshift = 4;\n \twhile (c & 0x80) {\n \t\tif (offset >= p->pack_size)\n \t\t\tdie(\"object offset outside of pack file\");\n-\t\tc = *pack++;\n-\t\toffset++;\n+\t\tc = *((unsigned char *)p->pack_base + offset++);\n \t\tsize += (c & 0x7f) << shift;\n \t\tshift += 7;\n \t}\n-- \n1.4.2.g6580\n"}]}