Skip to content

Commit fbd0943

Browse files
fshpgitster
authored andcommitted
stop_progress_msg: convert xsnprintf to xstrfmt
Simplify code by replacing buffer allocation with a call to xstrfmt(). Signed-off-by: Maxim Moseychuk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b9e3c2 commit fbd0943

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

progress.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
243243
*p_progress = NULL;
244244
if (progress->last_value != -1) {
245245
/* Force the last update */
246-
char buf[128], *bufp;
247-
size_t len = strlen(msg) + 5;
246+
char *buf;
248247
struct throughput *tp = progress->throughput;
249248

250-
bufp = (len < sizeof(buf)) ? buf : xmallocz(len);
251249
if (tp) {
252250
unsigned int rate = !tp->avg_misecs ? 0 :
253251
tp->avg_bytes / tp->avg_misecs;
254252
throughput_string(&tp->display, tp->curr_total, rate);
255253
}
256254
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);
261258
}
262259
clear_progress_signal();
263260
if (progress->throughput)

0 commit comments

Comments
 (0)