[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: [PATCH 34/34] wt-status: release strbuf after use in wt_longstatus_print_tracking()
From: Rene Scharfe <l.s.r () web ! de>
Date: 2017-08-30 18:20:18
Message-ID: 20170830182018.21390-1-l.s.r () web ! de
[Download RAW message or body]
If format_tracking_info() returns 0 only if it didn't touch its strbuf
parameter, so it's OK to exit early in that case. Clean up sb in the
other case.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
wt-status.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/wt-status.c b/wt-status.c
index cafafb5ecd..ac972acbab 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -998,34 +998,35 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
static void wt_longstatus_print_tracking(struct wt_status *s)
{
struct strbuf sb = STRBUF_INIT;
const char *cp, *ep, *branch_name;
struct branch *branch;
char comment_line_string[3];
int i;
assert(s->branch && !s->is_initial);
if (!skip_prefix(s->branch, "refs/heads/", &branch_name))
return;
branch = branch_get(branch_name);
if (!format_tracking_info(branch, &sb))
return;
i = 0;
if (s->display_comment_prefix) {
comment_line_string[i++] = comment_line_char;
comment_line_string[i++] = ' ';
}
comment_line_string[i] = '\0';
for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
"%s%.*s", comment_line_string,
(int)(ep - cp), cp);
if (s->display_comment_prefix)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "%c",
comment_line_char);
else
fputs("\n", s->fp);
+ strbuf_release(&sb);
}
static int has_unmerged(struct wt_status *s)
--
2.14.1
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic