projects
/
platform
/
upstream
/
kmod.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
405b892
)
strbuf: do not calculate next step in size on all calls
author
Lucas De Marchi
<lucas.demarchi@intel.com>
Fri, 17 Oct 2014 00:22:32 +0000
(21:22 -0300)
committer
Lucas De Marchi
<lucas.demarchi@intel.com>
Fri, 17 Oct 2014 00:22:32 +0000
(21:22 -0300)
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.
shared/strbuf.c
patch
|
blob
|
history
diff --git
a/shared/strbuf.c
b/shared/strbuf.c
index
a11f638
..
af445d9
100644
(file)
--- 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;