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>
This commit is contained in:
committed by
Junio C Hamano
parent
3b9e3c2ced
commit
fbd09439c0
11
progress.c
11
progress.c
@@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
|
|||||||
*p_progress = NULL;
|
*p_progress = NULL;
|
||||||
if (progress->last_value != -1) {
|
if (progress->last_value != -1) {
|
||||||
/* Force the last update */
|
/* Force the last update */
|
||||||
char buf[128], *bufp;
|
char *buf;
|
||||||
size_t len = strlen(msg) + 5;
|
|
||||||
struct throughput *tp = progress->throughput;
|
struct throughput *tp = progress->throughput;
|
||||||
|
|
||||||
bufp = (len < sizeof(buf)) ? buf : xmallocz(len);
|
|
||||||
if (tp) {
|
if (tp) {
|
||||||
unsigned int rate = !tp->avg_misecs ? 0 :
|
unsigned int rate = !tp->avg_misecs ? 0 :
|
||||||
tp->avg_bytes / tp->avg_misecs;
|
tp->avg_bytes / tp->avg_misecs;
|
||||||
throughput_string(&tp->display, tp->curr_total, rate);
|
throughput_string(&tp->display, tp->curr_total, rate);
|
||||||
}
|
}
|
||||||
progress_update = 1;
|
progress_update = 1;
|
||||||
xsnprintf(bufp, len + 1, ", %s.\n", msg);
|
buf = xstrfmt(", %s.\n", msg);
|
||||||
display(progress, progress->last_value, bufp);
|
display(progress, progress->last_value, buf);
|
||||||
if (buf != bufp)
|
free(buf);
|
||||||
free(bufp);
|
|
||||||
}
|
}
|
||||||
clear_progress_signal();
|
clear_progress_signal();
|
||||||
if (progress->throughput)
|
if (progress->throughput)
|
||||||
|
|||||||
Reference in New Issue
Block a user