diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-27 14:56:56 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-27 14:56:56 +0900 |
commit | 2903497e256388eff53b408875c0f2239c3566cb (patch) | |
tree | 347db66bc83651efce25eb72c422688936027b18 /src/util.c | |
parent | fd257fb9c490f4af3fbfb71c4d099fe876be28eb (diff) | |
download | libsolv-2903497e256388eff53b408875c0f2239c3566cb.tar.gz libsolv-2903497e256388eff53b408875c0f2239c3566cb.tar.bz2 libsolv-2903497e256388eff53b408875c0f2239c3566cb.zip |
Imported Upstream version 0.6.15upstream/0.6.15
Change-Id: Ifaa897b8285aab537e27433f14a18f11a4817c17
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -76,6 +76,30 @@ solv_calloc(size_t num, size_t len) return r; } +/* this was solv_realloc2(old, len, size), but we now overshoot + * for huge len sizes */ +void * +solv_extend_realloc(void *old, size_t len, size_t size, size_t block) +{ + size_t xblock = (block + 1) << 5; + len = (len + block) & ~block; + if (len >= xblock && xblock) + { + xblock <<= 1; + while (len >= xblock && xblock) + xblock <<= 1; + if (xblock) + { + size_t nlen; + xblock = (xblock >> 5) - 1; + nlen = (len + xblock) & ~xblock; + if (nlen > len) + len = nlen; + } + } + return solv_realloc2(old, len, size); +} + void * solv_free(void *mem) { |