diff options
author | Zeev Suraski <zeev@php.net> | 1999-04-10 14:44:35 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 1999-04-10 14:44:35 +0000 |
commit | 2e9886de3c4a155c45a16e74d2e6e4b7c6d31892 (patch) | |
tree | 596cc8a4cfa2f320026fde621962ba69d10dc602 | |
parent | e3d2234b80aac5d8defcd6fe9407ab621ba13c86 (diff) | |
download | php-git-2e9886de3c4a155c45a16e74d2e6e4b7c6d31892.tar.gz |
Get rid of php3_ini in Zend
-rw-r--r-- | Zend/zend_alloc.c | 20 | ||||
-rw-r--r-- | Zend/zend_alloc.h | 2 | ||||
-rw-r--r-- | Zend/zend_globals.h | 3 |
3 files changed, 21 insertions, 4 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 0336982a07..eb1cc68656 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -42,11 +42,11 @@ static zend_alloc_globals alloc_globals; # endif #define _CHECK_MEMORY_LIMIT(s,file,lineno) { AG(allocated_memory) += (s);\ - if (php3_ini.memory_limit<AG(allocated_memory)) {\ + if (AG(memory_limit)<AG(allocated_memory)) {\ if (!file) { \ - zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)",php3_ini.memory_limit,s); \ + zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", AG(memory_limit),s); \ } else { \ - zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)",php3_ini.memory_limit,file,lineno,s); \ + 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); \ } \ } \ } @@ -304,11 +304,25 @@ ZEND_API char *zend_strndup(const char *s, uint length) } +ZEND_API int set_memory_limit(unsigned int memory_limit) +{ +#if MEMORY_LIMIT + ALS_FETCH(); + + AG(memory_limit) = memory_limit; + return SUCCESS; +#else + return FAILURE; +#endif +} + + ZEND_API void start_memory_manager(void) { AG(phead) = AG(head) = NULL; #if MEMORY_LIMIT + AG(memory_limit)=1<<30; /* rediculous limit, effectively no limit */ AG(allocated_memory)=0; AG(memory_exhausted)=0; #endif diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 0caddae81f..9fe4d74320 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -92,6 +92,8 @@ ZEND_API void _persist_alloc(void *ptr); #define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string)) #define safe_estrndup(ptr,len) ((ptr)?(estrndup((ptr),(len))):(empty_string)) +ZEND_API int set_memory_limit(unsigned int memory_limit); + ZEND_API void start_memory_manager(void); ZEND_API void shutdown_memory_manager(int silent, int clean_cache); diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 7be0ce9c03..f20a7f5e6e 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -199,7 +199,8 @@ struct _zend_alloc_globals { void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; unsigned char cache_count[MAX_CACHED_MEMORY]; -# if MEMORY_LIMIT +#if MEMORY_LIMIT + unsigned int memory_limit; unsigned int allocated_memory; unsigned char memory_exhausted; #endif |