cvs: ZendEngine2(PHP_5_2) / zend_alloc.c php-src NEWS

[email protected] ("Dmitry Stogov")
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1225356909@cvsserver>
dmitry		Thu Oct 30 08:55:09 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src	NEWS 
    /ZendEngine2	zend_alloc.c 
  Log:
  Fixed ability to use "internal" heaps in extensions.
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1286&r2=1.2027.2.547.2.1287&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1286 php-src/NEWS:1.2027.2.547.2.1287
--- php-src/NEWS:1.2027.2.547.2.1286	Wed Oct 29 21:23:45 2008
+++ php-src/NEWS	Thu Oct 30 08:55:08 2008
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Nov 2008, PHP 5.2.7RC3
+- Fixed ability to use "internal" heaps in extensions. (Felipe, Dmitry)
 - Updated timezone database to version 2008.9. (Derick)
 
 - Fixed bug #46406 (Unregistering nodeclass throws E_FATAL). (Rob)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_alloc.c?r1=1.144.2.3.2.49&r2=1.144.2.3.2.50&diff_format=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.144.2.3.2.49 ZendEngine2/zend_alloc.c:1.144.2.3.2.50
--- ZendEngine2/zend_alloc.c:1.144.2.3.2.49	Mon Jul 21 17:06:55 2008
+++ ZendEngine2/zend_alloc.c	Thu Oct 30 08:55:09 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_alloc.c,v 1.144.2.3.2.49 2008/07/21 17:06:55 dmitry Exp $ */
+/* $Id: zend_alloc.c,v 1.144.2.3.2.50 2008/10/30 08:55:09 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_alloc.h"
@@ -1061,16 +1061,26 @@
 	}
 	if (internal) {
 		int i;
-		zend_mm_free_block *p;
+		zend_mm_free_block *p, *q, *orig;
 		zend_mm_heap *mm_heap = _zend_mm_alloc_int(heap, sizeof(zend_mm_heap)  ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC);
 
 		*mm_heap = *heap;
 
 		p = ZEND_MM_SMALL_FREE_BUCKET(mm_heap, 0);
+		orig = ZEND_MM_SMALL_FREE_BUCKET(heap, 0);
 		for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
-			p->prev_free_block->next_free_block = p;
-			p->next_free_block->prev_free_block = p;
+			q = p;
+			while (q->prev_free_block != orig) {
+				q = q->prev_free_block;
+			}
+			q->prev_free_block = p;
+			q = p;
+			while (q->next_free_block != orig) {
+				q = q->next_free_block;
+			}
+			q->next_free_block = p;
 			p = (zend_mm_free_block*)((char*)p + sizeof(zend_mm_free_block*) * 2);
+			orig = (zend_mm_free_block*)((char*)orig + sizeof(zend_mm_free_block*) * 2);
 			if (mm_heap->large_free_buckets[i]) {
 				mm_heap->large_free_buckets[i]->parent = &mm_heap->large_free_buckets[i];
 			}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.