summaryrefslogtreecommitdiff
path: root/Zend/zend_alloc.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-01-10 19:18:20 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-01-10 19:18:20 +0000
commit8c3b8d4fe6f26df6e9b081e7879d9c24a46d6fe0 (patch)
tree1f5b56e79aaae08075eccf190b03cc86ca204c7f /Zend/zend_alloc.c
parent9234916fc83629a724b5aaf0e46aa6de882caa62 (diff)
downloadphp-git-8c3b8d4fe6f26df6e9b081e7879d9c24a46d6fe0.tar.gz
MFZE2
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r--Zend/zend_alloc.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index d9df41dc63..340e2081e7 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -72,18 +72,22 @@ static long mem_block_end_magic = MEM_BLOCK_END_MAGIC;
#define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\
if (AG(memory_limit)<AG(allocated_memory)) {\
- if ((AG(memory_limit)+1048576)<AG(allocated_memory)) { \
- /* failed to handle this gracefully, exit() */ \
- exit(1); \
- } \
- if (!AG(memory_exhausted)) { \
- if (!file) { \
- zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", AG(memory_limit), s); \
+ int php_mem_limit = AG(memory_limit); \
+ if (AG(memory_limit)+1048576 > AG(allocated_memory) - rs) { \
+ AG(memory_limit) = AG(allocated_memory) + 1048576; \
+ if (file) { \
+ zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", php_mem_limit, s); \
} else { \
- zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", AG(memory_limit), file, lineno, s); \
+ zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", php_mem_limit, file, lineno, s); \
} \
- AG(memory_exhausted)=1; \
- } \
+ } else { \
+ if (file) { \
+ fprintf(stderr, "Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)\n", php_mem_limit, file, lineno, s); \
+ } else { \
+ fprintf(stderr, "Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)\n", php_mem_limit, s); \
+ } \
+ exit(1); \
+ } \
} \
}
# endif