]> granicus.if.org Git - php/commitdiff
Get rid of php3_ini in Zend
authorZeev Suraski <zeev@php.net>
Sat, 10 Apr 1999 14:44:35 +0000 (14:44 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 10 Apr 1999 14:44:35 +0000 (14:44 +0000)
Zend/zend_alloc.c
Zend/zend_alloc.h
Zend/zend_globals.h

index 0336982a0717cfea53a3c71fa98d7f1c2d691767..eb1cc68656e1a697a437d9e90fbd05cfc5332832 100644 (file)
@@ -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
index 0caddae81fdf810347f62c0031168566bc7fd911..9fe4d74320f6549fbb4b7e5eff939d1b0ba0a0e8 100644 (file)
@@ -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);
 
index 7be0ce9c034e3effbd7d1941a0cdcadce28feb74..f20a7f5e6ef3e721dd810685eac96bc79d013a46 100644 (file)
@@ -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