Don't shrink a talloc area if we have less than 1k to gain
authorVolker Lendecke <vl@samba.org>
Tue, 8 Jan 2008 21:42:27 +0000 (22:42 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 11 Feb 2008 14:07:46 +0000 (15:07 +0100)
source/lib/talloc/talloc.c

index f9aefcd6de236f07d18fcdb94a0b40fdae3b9cb6..7aad42ce8cc571d8865002fb5b5f8fe9bbdd6770 100644 (file)
@@ -787,6 +787,11 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
 
        tc = talloc_chunk_from_ptr(ptr);
 
+       if ((size < tc->size) && ((tc->size - size) < 1024)) {
+               tc->size = size;
+               return ptr;
+       }
+
        /* don't allow realloc on referenced pointers */
        if (unlikely(tc->refs)) {
                return NULL;