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>
Maxim Moseychuk committed
Feb 16, 2017 at 20:07 UTC
fbd09439c097123346d9823b88c87438bf5a11ae
1 file changed
+4
-7
progress.c
+4
-7
@@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
243
*p_progress = NULL;
244
if (progress->last_value != -1) {
245
/* Force the last update */
246
- char buf[128], *bufp;
247
- size_t len = strlen(msg) + 5;
246
+ char *buf;
247
struct throughput *tp = progress->throughput;
248
250
- bufp = (len < sizeof(buf)) ? buf : xmallocz(len);
249
if (tp) {
250
unsigned int rate = !tp->avg_misecs ? 0 :
251
tp->avg_bytes / tp->avg_misecs;
252
throughput_string(&tp->display, tp->curr_total, rate);
253
}
254
progress_update = 1;
257
- xsnprintf(bufp, len + 1, ", %s.\n", msg);
258
- display(progress, progress->last_value, bufp);
259
- if (buf != bufp)
260
- free(bufp);
255
+ buf = xstrfmt(", %s.\n", msg);
256
+ display(progress, progress->last_value, buf);
257
+ free(buf);
258
}
259
clear_progress_signal();
260
if (progress->throughput)