Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43284 invoked by uid 1010); 28 Oct 2003 22:28:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 43260 invoked by uid 1007); 28 Oct 2003 22:28:55 -0000 Message-ID: <20031028222855.43259.qmail@pb1.pair.com> To: internals@lists.php.net Date: Tue, 28 Oct 2003 20:29:00 -0200 User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4.1) Gecko/20031008 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <20031026165338.18992.qmail@pb1.pair.com> <5.1.0.14.2.20031026213148.03145288@127.0.0.1> <20031027235352.79424.qmail@pb1.pair.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------080201040705070809050705" X-Posted-By: 200.196.104.198 Subject: Re: [PHP-DEV] internal hashtables [patch included] From: cunha17@uol.com.br (Cristiano Duarte) --------------080201040705070809050705 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Derick Rethans wrote: > Can you please not send uuencoded stuff but just attach the files as > plain text? Sorry Derick, I didn't mean to. :-( The patch is attached as plain text now. Cristiano Duarte --------------080201040705070809050705 Content-Type: text/plain; name="ze2_internal_symtables.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ze2_internal_symtables.patch" ? php-src/ZendEngine1 Index: php-src/Zend/zend_alloc.c =================================================================== RCS file: /repository/ZendEngine2/zend_alloc.c,v retrieving revision 1.129 diff -u -r1.129 zend_alloc.c --- php-src/Zend/zend_alloc.c 17 Oct 2003 02:29:06 -0000 1.129 +++ php-src/Zend/zend_alloc.c 26 Oct 2003 16:57:39 -0000 @@ -477,6 +477,10 @@ zend_uint grand_total_leaks=0; #endif + if (zend_internal_nOfHashTables() > 0) { + zend_gc_destroy_internal_hashtables(); + } + #if defined(ZEND_MM) && !ZEND_DEBUG if (clean_cache) { zend_mm_shutdown(&AG(mm_heap)); Index: php-src/Zend/zend_hash.c =================================================================== RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.113 diff -u -r1.113 zend_hash.c --- php-src/Zend/zend_hash.c 29 Aug 2003 07:34:37 -0000 1.113 +++ php-src/Zend/zend_hash.c 26 Oct 2003 16:57:40 -0000 @@ -1313,6 +1313,48 @@ } #endif +struct _internal_hashtables { + HashTable **list; + int nOfHashTables; +}; +struct _internal_hashtables *internal_hashtables = NULL; + +int zend_internal_nOfHashTables() { + return (internal_hashtables == NULL) ? 0 : internal_hashtables->nOfHashTables; +} + +void zend_gc_add_internal_hashtable(HashTable *ht TSRMLS_DC) { + HashTable **ptr; + if (internal_hashtables == NULL) { + internal_hashtables = malloc(sizeof(struct _internal_hashtables)); + internal_hashtables->nOfHashTables = 0; + internal_hashtables->list = NULL; + } + internal_hashtables->list = realloc(internal_hashtables->list, sizeof(HashTable*) * (internal_hashtables->nOfHashTables + 1)); + ptr = internal_hashtables->list; + ptr += internal_hashtables->nOfHashTables; + *ptr = ht; + ++(internal_hashtables->nOfHashTables); +} + +void zend_gc_destroy_internal_hashtables() { + HashTable **ptr; + if (internal_hashtables != NULL) { + ptr = internal_hashtables->list; + if (ptr != NULL) { + int i; + for (i = 0; i < internal_hashtables->nOfHashTables; ++i) { + zend_hash_destroy(*ptr); + ++ptr; + } + free(internal_hashtables->list); + internal_hashtables->list = NULL; + free(internal_hashtables); + internal_hashtables = NULL; + } + } +} + /* * Local variables: * tab-width: 4 Index: php-src/Zend/zend_hash.h =================================================================== RCS file: /repository/ZendEngine2/zend_hash.h,v retrieving revision 1.75 diff -u -r1.75 zend_hash.h --- php-src/Zend/zend_hash.h 25 Sep 2003 15:38:35 -0000 1.75 +++ php-src/Zend/zend_hash.h 26 Oct 2003 16:57:40 -0000 @@ -350,6 +350,14 @@ return zend_hash_exists(ht, arKey, nKeyLength); } +#define ZEND_INIT_INTERNAL_SYMTABLE(ht) \ + ZEND_INIT_SYMTABLE(ht); \ + zend_gc_add_internal_hashtable(ht TSRMLS_CC); + +int zend_internal_nOfHashTables(); +void zend_gc_add_internal_hashtable(HashTable *ht TSRMLS_DC); +void zend_gc_destroy_internal_hashtables(); + #endif /* ZEND_HASH_H */ /* --------------080201040705070809050705--