diff options
author | Stanislav Malyshev <stas@php.net> | 2000-06-22 17:51:14 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2000-06-22 17:51:14 +0000 |
commit | bb57053f7608838de53b66f9d83c751573d2e69f (patch) | |
tree | 88209cb6e60a6e7693b7b48ccd2355da244f6517 /Zend/zend_alloc.c | |
parent | 7f87a319aa0a769162a13bdb20ae23fc724b21ac (diff) | |
download | php-git-bb57053f7608838de53b66f9d83c751573d2e69f.tar.gz |
Cached-freed memory blocks should not be in "occupied" list
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r-- | Zend/zend_alloc.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 606a38b380..ae1449eb66 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -135,6 +135,9 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) p->persistent = 0; p->cached = 0; p->size = size; + HANDLE_BLOCK_INTERRUPTIONS(); + ADD_POINTER_TO_LIST(p); + HANDLE_UNBLOCK_INTERRUPTIONS(); return (void *)((char *)p + sizeof(zend_mem_header) + PLATFORM_PADDING); } else { #if ZEND_DEBUG @@ -198,6 +201,9 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) #if ZEND_DEBUG p->magic = MEM_BLOCK_CACHED_MAGIC; #endif + HANDLE_BLOCK_INTERRUPTIONS(); + REMOVE_POINTER_FROM_LIST(p); + HANDLE_UNBLOCK_INTERRUPTIONS(); return; } HANDLE_BLOCK_INTERRUPTIONS(); @@ -355,7 +361,7 @@ ZEND_API void start_memory_manager(ALS_D) #endif memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head))); - memset(AG(cache_count),0,MAX_CACHED_MEMORY*sizeof(unsigned int)); + memset(AG(cache_count),0,sizeof(AG(cache_count))); #ifndef ZTS /* Initialize cache, to prevent fragmentation */ @@ -378,21 +384,19 @@ ZEND_API void start_memory_manager(ALS_D) memset(AG(cache_stats), 0, sizeof(AG(cache_stats))); memset(AG(fast_cache_stats), 0, sizeof(AG(fast_cache_stats))); #endif - } ZEND_API void shutdown_memory_manager(int silent, int clean_cache) { zend_mem_header *p, *t; - int fci; + int fci,i,j; #if ZEND_DEBUG int had_leaks=0; #endif zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry; ALS_FETCH(); - for (fci=0; fci<MAX_FAST_CACHE_TYPES; fci++) { fast_cache_list_entry = AG(fast_cache_list_head)[fci]; while (fast_cache_list_entry) { @@ -440,6 +444,14 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache) } } + if(clean_cache) { + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<AG(cache_count)[i]; j++) { + free(AG(cache)[i][j]); + } + } + } + #if (ZEND_DEBUG) do { zval display_memory_cache_stats; |