diff options
author | Nicolas Pitre <nico@cam.org> | 2007-03-16 16:42:50 -0400 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-03-16 21:27:36 -0700 |
commit | 4287307833a7c67b09973fc1023311e473f830b2 (patch) | |
tree | 73148a57513bc2002138b86d184c1ec20f73ebf9 /builtin-pack-objects.c | |
parent | ac527b0b7c9be37ad7f2f7d871b6e9b41fd0c431 (diff) | |
download | git-4287307833a7c67b09973fc1023311e473f830b2.tar.gz |
[PATCH] clean up pack index handling a bit
Especially with the new index format to come, it is more appropriate
to encapsulate more into check_packed_git_idx() and assume less of the
index format in struct packed_git.
To that effect, the index_base is renamed to index_data with void * type
so it is not used directly but other pointers initialized with it. This
allows for a couple pointer cast removal, as well as providing a better
generic name to grep for when adding support for new index versions or
formats.
And index_data is declared const too while at it.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index f8ebad0b2f..73d448b890 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -166,11 +166,12 @@ static void prepare_pack_revindex(struct pack_revindex *rix) struct packed_git *p = rix->p; int num_ent = num_packed_objects(p); int i; - void *index = p->index_base + 256; + const char *index = p->index_data; + index += 4 * 256; rix->revindex = xmalloc(sizeof(*rix->revindex) * (num_ent + 1)); for (i = 0; i < num_ent; i++) { - unsigned int hl = *((unsigned int *)((char *) index + 24*i)); + uint32_t hl = *((uint32_t *)(index + 24 * i)); rix->revindex[i].offset = ntohl(hl); rix->revindex[i].nr = i; } @@ -217,11 +218,11 @@ static off_t find_packed_object_size(struct packed_git *p, off_t ofs) return entry[1].offset - ofs; } -static unsigned char *find_packed_object_name(struct packed_git *p, - off_t ofs) +static const unsigned char *find_packed_object_name(struct packed_git *p, + off_t ofs) { struct revindex_entry *entry = find_packed_object(p, ofs); - return (unsigned char *)(p->index_base + 256) + 24 * entry->nr + 4; + return ((unsigned char *)p->index_data) + 4 * 256 + 24 * entry->nr + 4; } static void *delta_against(void *buf, unsigned long size, struct object_entry *entry) @@ -996,7 +997,8 @@ static void check_object(struct object_entry *entry) * delta. */ if (!no_reuse_delta) { - unsigned char c, *base_name; + unsigned char c; + const unsigned char *base_name; off_t ofs; unsigned long used_0; /* there is at least 20 bytes left in the pack */ |