cvs: ZendEngine2 / zend_alloc.c

From: Date: Mon, 10 May 2004 12:17:25 +0000
Subject: cvs: ZendEngine2 / zend_alloc.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2629@lists.php.net to get a copy of this message
sesser Mon May 10 08:17:25 2004 EDT Modified files: /ZendEngine2 zend_alloc.c Log: Checking MEMORY_LIMIT before doing emalloc/erealloc solves several ugly problems. http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.c?r1=1.130&r2=1.131&ty=u Index: ZendEngine2/zend_alloc.c diff -u ZendEngine2/zend_alloc.c:1.130 ZendEngine2/zend_alloc.c:1.131 --- ZendEngine2/zend_alloc.c:1.130 Thu Jan 8 12:31:47 2004 +++ ZendEngine2/zend_alloc.c Mon May 10 08:17:25 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_alloc.c,v 1.130 2004/01/08 17:31:47 sniper Exp $ */ +/* $Id: zend_alloc.c,v 1.131 2004/05/10 12:17:25 sesser Exp $ */ #include "zend.h" #include "zend_alloc.h" @@ -165,6 +165,12 @@ AG(cache_stats)[CACHE_INDEX][0]++; } #endif +#if MEMORY_LIMIT + CHECK_MEMORY_LIMIT(size, SIZE); + if (AG(allocated_memory) > AG(allocated_memory_peak)) { + AG(allocated_memory_peak) = AG(allocated_memory); + } +#endif p = (zend_mem_header *) ZEND_DO_MALLOC(sizeof(zend_mem_header) + MEM_HEADER_PADDING + SIZE + END_MAGIC_SIZE); #if !ZEND_DISABLE_MEMORY_CACHE } @@ -199,12 +205,6 @@ # endif memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long)); #endif -#if MEMORY_LIMIT - CHECK_MEMORY_LIMIT(size, SIZE); - if (AG(allocated_memory) > AG(allocated_memory_peak)) { - AG(allocated_memory_peak) = AG(allocated_memory); - } -#endif HANDLE_UNBLOCK_INTERRUPTIONS(); return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING); @@ -331,6 +331,12 @@ CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size); HANDLE_BLOCK_INTERRUPTIONS(); +#if MEMORY_LIMIT + CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size)); + if (AG(allocated_memory) > AG(allocated_memory_peak)) { + AG(allocated_memory_peak) = AG(allocated_memory); + } +#endif #if ZEND_DEBUG || !defined(ZEND_MM) REMOVE_POINTER_FROM_LIST(p); #endif @@ -359,12 +365,6 @@ p->magic = MEM_BLOCK_START_MAGIC; memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long)); #endif -#if MEMORY_LIMIT - CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size)); - if (AG(allocated_memory) > AG(allocated_memory_peak)) { - AG(allocated_memory_peak) = AG(allocated_memory); - } -#endif p->size = size;

« previous php.zend-engine.cvs (#2629) next »