diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2017-03-26 19:01:24 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-27 08:08:21 +0300 |
commit | dc01505f7f272a44b974e622f75bd592debe9dcb (patch) | |
tree | 7aa62babd604067a3d928edfa988391711a36007 /sha1_name.c | |
parent | 5028bf628c7ebfb85d14ec7dc296b264a1c3bcd3 (diff) |
Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ
Since we will likely be introducing a new hash function at some point,
and that hash function might be longer than 40 hex characters, use the
constant GIT_MAX_HEXSZ, which is designed to be suitable for
allocations, instead of GIT_SHA1_HEXSZ. This will ease the transition
down the line by distinguishing between places where we need to allocate
memory suitable for the largest hash from those where we need to handle
the current hash.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sha1_name.c b/sha1_name.c index cda9e49b12..964201bc26 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -15,7 +15,7 @@ typedef int (*disambiguate_hint_fn)(const unsigned char *, void *); struct disambiguate_state { int len; /* length of prefix in hex chars */ - char hex_pfx[GIT_SHA1_HEXSZ + 1]; + char hex_pfx[GIT_MAX_HEXSZ + 1]; unsigned char bin_pfx[GIT_SHA1_RAWSZ]; disambiguate_hint_fn fn; @@ -80,7 +80,7 @@ static void update_candidates(struct disambiguate_state *ds, const unsigned char static void find_short_object_filename(struct disambiguate_state *ds) { struct alternate_object_database *alt; - char hex[GIT_SHA1_HEXSZ]; + char hex[GIT_MAX_HEXSZ]; static struct alternate_object_database *fakeent; if (!fakeent) { @@ -509,7 +509,7 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len) const char *find_unique_abbrev(const unsigned char *sha1, int len) { static int bufno; - static char hexbuffer[4][GIT_SHA1_HEXSZ + 1]; + static char hexbuffer[4][GIT_MAX_HEXSZ + 1]; char *hex = hexbuffer[bufno]; bufno = (bufno + 1) % ARRAY_SIZE(hexbuffer); find_unique_abbrev_r(hex, sha1, len); |