summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>2017-02-16 17:07:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-16 19:28:02 (GMT)
commitfbd09439c097123346d9823b88c87438bf5a11ae (patch)
treef346e2791b612d6c5492857fa109017057018e95
parent3b9e3c2cede15057af3ff8076c45ad5f33829436 (diff)
downloadgit-fbd09439c097123346d9823b88c87438bf5a11ae.zip
git-fbd09439c097123346d9823b88c87438bf5a11ae.tar.gz
git-fbd09439c097123346d9823b88c87438bf5a11ae.tar.bz2
stop_progress_msg: convert xsnprintf to xstrfmt
Simplify code by replacing buffer allocation with a call to xstrfmt(). Signed-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--progress.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/progress.c b/progress.c
index 76a88c5..29378ca 100644
--- a/progress.c
+++ b/progress.c
@@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
*p_progress = NULL;
if (progress->last_value != -1) {
/* Force the last update */
- char buf[128], *bufp;
- size_t len = strlen(msg) + 5;
+ char *buf;
struct throughput *tp = progress->throughput;
- bufp = (len < sizeof(buf)) ? buf : xmallocz(len);
if (tp) {
unsigned int rate = !tp->avg_misecs ? 0 :
tp->avg_bytes / tp->avg_misecs;
throughput_string(&tp->display, tp->curr_total, rate);
}
progress_update = 1;
- xsnprintf(bufp, len + 1, ", %s.\n", msg);
- display(progress, progress->last_value, bufp);
- if (buf != bufp)
- free(bufp);
+ buf = xstrfmt(", %s.\n", msg);
+ display(progress, progress->last_value, buf);
+ free(buf);
}
clear_progress_signal();
if (progress->throughput)