Author: chromatic
Date: Tue Apr 24 12:25:28 2007
New Revision: 18323

Modified:
   trunk/src/gc/resources.c

Log:
[GC] Don't allocate strings of size zero.  Strings with empty buffers work just 
fine, and strings of size zero are a pathological case for the pool compactor.

See RT #42320.

Modified: trunk/src/gc/resources.c
==============================================================================
--- trunk/src/gc/resources.c    (original)
+++ trunk/src/gc/resources.c    Tue Apr 24 12:25:28 2007
@@ -744,6 +744,13 @@
     PObj_buflen(str)   = 0;
     PObj_bufstart(str) = NULL;
 
+    /* there's no sense in allocating zero memory, when the overhead of
+     * allocating a string is one pointer; this can fill the pools in an
+     * uncompactable way.  See RT #42320.
+     */
+    if (size == 0)
+        return;
+
     pool     = PObj_constant_TEST(str)
                 ? interp->arena_base->constant_string_pool
                 : interp->arena_base->memory_pool;

Reply via email to