Commit 00e85927 by Russell Belfer

Clean up unnecessary git_buf_printf calls

This replaces some git_buf_printf calls with simple calls to
git_buf_put instead.  Also, it fixes a missing va_end inside
the git_buf_vprintf implementation.
parent 71379313
...@@ -211,6 +211,8 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) ...@@ -211,6 +211,8 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
format, args format, args
); );
va_end(args);
if (len < 0) { if (len < 0) {
git__free(buf->ptr); git__free(buf->ptr);
buf->ptr = git_buf__oom; buf->ptr = git_buf__oom;
......
...@@ -336,7 +336,7 @@ static int diff_print_patch_hunk( ...@@ -336,7 +336,7 @@ static int diff_print_patch_hunk(
return 0; return 0;
git_buf_clear(pi->buf); git_buf_clear(pi->buf);
if (git_buf_printf(pi->buf, "%.*s", (int)header_len, header) < 0) if (git_buf_put(pi->buf, header, header_len) < 0)
return -1; return -1;
if (pi->print_cb(d, r, GIT_DIFF_LINE_HUNK_HDR, if (pi->print_cb(d, r, GIT_DIFF_LINE_HUNK_HDR,
...@@ -360,13 +360,14 @@ static int diff_print_patch_line( ...@@ -360,13 +360,14 @@ static int diff_print_patch_line(
return 0; return 0;
git_buf_clear(pi->buf); git_buf_clear(pi->buf);
git_buf_grow(pi->buf, content_len + 2);
if (line_origin == GIT_DIFF_LINE_ADDITION || if (line_origin == GIT_DIFF_LINE_ADDITION ||
line_origin == GIT_DIFF_LINE_DELETION || line_origin == GIT_DIFF_LINE_DELETION ||
line_origin == GIT_DIFF_LINE_CONTEXT) line_origin == GIT_DIFF_LINE_CONTEXT)
git_buf_printf(pi->buf, "%c%.*s", line_origin, (int)content_len, content); git_buf_putc(pi->buf, line_origin);
else if (content_len > 0)
git_buf_printf(pi->buf, "%.*s", (int)content_len, content); git_buf_put(pi->buf, content, content_len);
if (git_buf_oom(pi->buf)) if (git_buf_oom(pi->buf))
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment