summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b7b2055)
raw | patch | inline | side by side (parent: b7b2055)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 16 May 2014 06:48:40 +0000 (08:48 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 16 May 2014 06:48:40 +0000 (08:48 +0200) |
Previously, resizing happened "too early" which may possibly generate
avoidable memory churn.
avoidable memory churn.
src/utils/strbuf.c | patch | blob | history |
diff --git a/src/utils/strbuf.c b/src/utils/strbuf.c
index 6c881be18e4975517f4c5080747e5d6f83a183f1..0474677296c31f9c1fcce3ded0a0207fde621c8a 100644 (file)
--- a/src/utils/strbuf.c
+++ b/src/utils/strbuf.c
}
/* 'status' does not include nul-byte */
- if ((size_t)status >= strbuf->size - strbuf->pos - 1) {
- if (strbuf_resize(strbuf, strbuf->size + (size_t)status + 1)) {
+ if ((size_t)status >= strbuf->size - strbuf->pos) {
+ if (strbuf_resize(strbuf, strbuf->pos + (size_t)status + 1)) {
va_end(aq);
return -1;
}