scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit 829aa28bdfe35b3c0357fd13164bfd1868298d7a
parent b8a54a3191397d05409e02952cb565224a7074b9
Author: sin <sin@2f30.org>
Date:   Thu,  1 Aug 2013 15:14:50 +0100

Re-use allocated space if we were asked to shrink it

Diffstat:
Mrandom/rballoc.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/random/rballoc.c b/random/rballoc.c @@ -149,6 +149,10 @@ realloc(void *oldp, size_t siz) * at address `oldp' */ res = RB_FIND(alloc_tree, &at, &n); if (res) { + /* If we were asked to shrink the allocated space + * just re-use it */ + if (res->siz >= siz) + return res->buf; p = malloc(siz); if (!p) return NULL;