summaryrefslogtreecommitdiff
path: root/hex.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'sb/hex-object-name-is-at-most-41-bytes-long'Junio C Hamano2015-02-251-1/+1
|\ | | | | | | | | | | | | Code clean-up. * sb/hex-object-name-is-at-most-41-bytes-long: hex.c: reduce memory footprint of sha1_to_hex static buffers
| * hex.c: reduce memory footprint of sha1_to_hex static bufferssb/hex-object-name-is-at-most-41-bytes-longStefan Beller2015-02-131-1/+1
| | | | | | | | | | | | | | | | | | 41 bytes is the exact number of bytes needed for having the returned hex string represented. 50 seems to be an arbitrary number, such that there are no benefits from alignment to certain address boundaries. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | get_sha1_hex(): do not read past a NUL characterMichael Haggerty2011-10-051-1/+9
|/ | | | | | | | | | | | | | | | Previously, get_sha1_hex() would read one character past the end of a null-terminated string whose strlen was an even number less than 40. Although the function correctly returned -1 in these cases, the extra memory access might have been to uninitialized (or even, conceivably, unallocated) memory. Add a check to avoid reading past the end of a string. This problem was discovered by Thomas Rast <trast@student.ethz.ch> using valgrind. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* slim down "git show-index"Linus Torvalds2010-01-211-0/+67
As the documentation says, this is primarily for debugging, and in the longer term we should rename it to test-show-index or something. In the meantime, just avoid xmalloc (which slurps in the rest of git), and separating out the trivial hex functions into "hex.o". This results in [torvalds@nehalem git]$ size git-show-index text data bss dec hex filename 222818 2276 112688 337782 52776 git-show-index (before) 5696 624 1264 7584 1da0 git-show-index (after) which is a whole lot better. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>