dmitry                                   Wed, 08 Sep 2010 07:52:49 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=303162

Log:
We don't need to preallocate a memory segment in case we don't use zend memory 
manager

Changed paths:
    U   php/php-src/trunk/Zend/zend_alloc.c

Modified: php/php-src/trunk/Zend/zend_alloc.c
===================================================================
--- php/php-src/trunk/Zend/zend_alloc.c 2010-09-08 05:40:42 UTC (rev 303161)
+++ php/php-src/trunk/Zend/zend_alloc.c 2010-09-08 07:52:49 UTC (rev 303162)
@@ -1568,6 +1568,10 @@
        zend_mm_segment *prev;
        int internal;

+       if (!heap->use_zend_alloc) {
+               return;
+       }
+
        if (heap->reserve) {
 #if ZEND_DEBUG
                if (!silent) {
@@ -2581,17 +2585,17 @@

 static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
 {
-       char *tmp;
-       alloc_globals->mm_heap = zend_mm_startup();
+       char *tmp = getenv("USE_ZEND_ALLOC");

-       tmp = getenv("USE_ZEND_ALLOC");
-       if (tmp) {
-               alloc_globals->mm_heap->use_zend_alloc = zend_atoi(tmp, 0);
-               if (!alloc_globals->mm_heap->use_zend_alloc) {
-                       alloc_globals->mm_heap->_malloc = malloc;
-                       alloc_globals->mm_heap->_free = free;
-                       alloc_globals->mm_heap->_realloc = realloc;
-               }
+       if (tmp && !zend_atoi(tmp, 0)) {
+               alloc_globals->mm_heap = malloc(sizeof(struct _zend_mm_heap));
+               memset(alloc_globals->mm_heap, 0, sizeof(struct _zend_mm_heap));
+               alloc_globals->mm_heap->use_zend_alloc = 0;
+               alloc_globals->mm_heap->_malloc = malloc;
+               alloc_globals->mm_heap->_free = free;
+               alloc_globals->mm_heap->_realloc = realloc;
+       } else {
+               alloc_globals->mm_heap = zend_mm_startup();
        }
 }


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to