summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2014-10-16 21:22:32 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2014-10-16 21:22:32 -0300
commit8863154e446d6b60ff6afd6572ce5d9c9651a59c (patch)
tree9174327b8397e4a5dc05521956b88122208dedae /shared
parent405b8927fe36df633f70cbed74f1aab1fea0b947 (diff)
downloadkmod-8863154e446d6b60ff6afd6572ce5d9c9651a59c.tar.gz
strbuf: do not calculate next step in size on all calls
We only need to check if the new size is less or equal than the current size. We don't really need to calculate the next step.
Diffstat (limited to 'shared')
-rw-r--r--shared/strbuf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/shared/strbuf.c b/shared/strbuf.c
index a11f638..af445d9 100644
--- a/shared/strbuf.c
+++ b/shared/strbuf.c
@@ -33,14 +33,14 @@ static bool buf_grow(struct strbuf *buf, size_t newsize)
void *tmp;
size_t sz;
+ if (newsize <= buf->size)
+ return true;
+
if (newsize % BUF_STEP == 0)
sz = newsize;
else
sz = ((newsize / BUF_STEP) + 1) * BUF_STEP;
- if (buf->size == sz)
- return true;
-
tmp = realloc(buf->bytes, sz);
if (sz > 0 && tmp == NULL)
return false;