diff options
author | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2011-12-08 16:35:08 -0200 |
---|---|---|
committer | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2011-12-08 16:35:36 -0200 |
commit | 435ad788e25effe953816ed39b4ae914ce22cf04 (patch) | |
tree | 16e9d641fc02e3e2fd2b993a7076785e17a3feb4 /libkmod | |
parent | 405f614af978576586ef5aa2444cfa30ae132284 (diff) | |
download | kmod-435ad788e25effe953816ed39b4ae914ce22cf04.tar.gz |
reduce calls to realloc() if size did not change.
Diffstat (limited to 'libkmod')
-rw-r--r-- | libkmod/libkmod-index.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index c3252fe..a0cb510 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -120,6 +120,9 @@ static bool buf_grow(struct buffer *buf, size_t 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; |