Skip to content

Commit b45a09c

Browse files
drafnelgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9d33f7c commit b45a09c

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

sha1_name.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,6 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
777777
for_each_recent_reflog_ent("HEAD", grab_nth_branch_switch, 40960, &cb);
778778
if (cb.cnt < nth) {
779779
cb.cnt = 0;
780-
for (i = 0; i < nth; i++)
781-
strbuf_release(&cb.buf[i]);
782780
for_each_reflog_ent("HEAD", grab_nth_branch_switch, &cb);
783781
}
784782
if (cb.cnt < nth)

0 commit comments

Comments
 (0)