Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
shorten_unambiguous_ref(): tighten up pointer arithmetic
author
Michael Haggerty
<mhagger@alum.mit.edu>
Wed, 8 Jan 2014 14:43:40 +0000
(15:43 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 9 Jan 2014 23:02:36 +0000
(15:02 -0800)
As long as we're being pathologically stingy with mallocs, we might as
well do the math right and save 6 (!) bytes.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(from parent 1:
4346663
)
diff --git
a/refs.c
b/refs.c
index 5e54af267abf91646e754b283c9b89f5dc2ca1bb..676bfd550e742b87cae0f6cbbd6fa6e7e643057a 100644
(file)
--- a/
refs.c
+++ b/
refs.c
@@
-3353,8
+3353,8
@@
char *shorten_unambiguous_ref(const char *refname, int strict)
/* the rule list is NULL terminated, count them first */
for (nr_rules = 0; ref_rev_parse_rules[nr_rules]; nr_rules++)
- /*
no +1 because strlen("%s") < strlen("%.*s")
*/
- total_len += strlen(ref_rev_parse_rules[nr_rules]);
+ /*
-2 for strlen("%.*s") - strlen("%s"); +1 for NUL
*/
+ total_len += strlen(ref_rev_parse_rules[nr_rules])
- 2 + 1
;
scanf_fmts = xmalloc(nr_rules * sizeof(char *) + total_len);