From: Gustavo Sverzut Barbieri Date: Thu, 8 Dec 2011 18:35:08 +0000 (-0200) Subject: reduce calls to realloc() if size did not change. X-Git-Tag: v1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=435ad788e25effe953816ed39b4ae914ce22cf04;p=thirdparty%2Fkmod.git reduce calls to realloc() if size did not change. --- diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index c3252fed..a0cb510a 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;