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
? 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 */
 
 /*

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to