Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
stop_progress_msg: convert xsnprintf to xstrfmt
author
Maxim Moseychuk
<franchesko.salias.hudro.pedros@gmail.com>
Thu, 16 Feb 2017 17:07:13 +0000
(20:07 +0300)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 16 Feb 2017 19:28:02 +0000
(11:28 -0800)
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>
progress.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
3b9e3c2
)
diff --git
a/progress.c
b/progress.c
index 76a88c573f7895bbf388ab4335faa1b86c3975d3..29378caa05336efe15cdf2a9473ca6cbe2bcfa14 100644
(file)
--- 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 */
*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;
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;
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)
}
clear_progress_signal();
if (progress->throughput)