sha1_name.c: avoid unnecessary strbuf_release
When we fall back to a standard for_each_reflog_ent() after failing to find the nth branch switch (or if we had a short reflog) with the call to for_each_recent_reflog_ent(), we do not need to free the memory allocated for our strbuf's since a strbuf_reset() will be performed in grab_nth_branch_switch() before assigning to the entry. Plus, the strbuf_release() negates the non-zero hint we initially gave to strbuf_init() just above these lines. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Jul 16, 2009 at 16:25 UTC
b45a09c4b4a80ccc6eeb0f390ab8f4eb6f31c922
1 file changed
-2
sha1_name.c
-2
@@ -777,8 +777,6 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
777
for_each_recent_reflog_ent("HEAD", grab_nth_branch_switch, 40960, &cb);
778
if (cb.cnt < nth) {
779
cb.cnt = 0;
780
- for (i = 0; i < nth; i++)
781
- strbuf_release(&cb.buf[i]);
780
for_each_reflog_ent("HEAD", grab_nth_branch_switch, &cb);
781
}
782
if (cb.cnt < nth)