[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
davidc Sat Nov 22 14:19:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_007.phpt pqueue_003.phpt Log: - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap-key() - Adjusted the tests http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.1.2.11r2=1.1.2.12diff_format=u Index: php-src/ext/spl/spl_heap.c diff -u php-src/ext/spl/spl_heap.c:1.1.2.11 php-src/ext/spl/spl_heap.c:1.1.2.12 --- php-src/ext/spl/spl_heap.c:1.1.2.11 Mon Nov 17 11:27:59 2008 +++ php-src/ext/spl/spl_heap.c Sat Nov 22 14:19:47 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_heap.c,v 1.1.2.11 2008/11/17 11:27:59 felipe Exp $ */ +/* $Id: spl_heap.c,v 1.1.2.12 2008/11/22 14:19:47 davidc Exp $ */ #ifdef HAVE_CONFIG_H # include config.h @@ -970,8 +970,8 @@ SPL_METHOD(SplHeap, key) { spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC); - - RETURN_LONG(intern-heap-count); + + RETURN_LONG(intern-heap-count - 1); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/heap_007.phpt?r1=1.1.2.3r2=1.1.2.4diff_format=u Index: php-src/ext/spl/tests/heap_007.phpt diff -u php-src/ext/spl/tests/heap_007.phpt:1.1.2.3 php-src/ext/spl/tests/heap_007.phpt:1.1.2.4 --- php-src/ext/spl/tests/heap_007.phpt:1.1.2.3 Sat May 24 14:10:44 2008 +++ php-src/ext/spl/tests/heap_007.phpt Sat Nov 22 14:19:47 2008 @@ -12,6 +12,7 @@ $h-rewind(); echo count(\$h) = .count($h).\n; echo \$h-count() = .$h-count().\n; + while ($h-valid()) { $k = $h-key(); $v = $h-current(); @@ -24,8 +25,8 @@ --EXPECTF-- count($h) = 4 $h-count() = 4 -4=5 -3=4 -2=1 -1=0 +3=5 +2=4 +1=1 +0=0 ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/pqueue_003.phpt?r1=1.1.2.3r2=1.1.2.4diff_format=u Index: php-src/ext/spl/tests/pqueue_003.phpt diff -u php-src/ext/spl/tests/pqueue_003.phpt:1.1.2.3 php-src/ext/spl/tests/pqueue_003.phpt:1.1.2.4 --- php-src/ext/spl/tests/pqueue_003.phpt:1.1.2.3 Sat May 24 14:10:44 2008 +++ php-src/ext/spl/tests/pqueue_003.phpt Sat Nov 22 14:19:47 2008 @@ -24,8 +24,8 @@ --EXPECTF-- count($h) = 4 $h-count() = 4 -4=5 -3=4 -2=1 -1=0 +3=5 +2=4 +1=1 +0=0 ===DONE=== -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
2008/11/22 David Coallier [EMAIL PROTECTED]: davidc Sat Nov 22 14:19:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_007.phpt pqueue_003.phpt Log: - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap-key() - Adjusted the tests Hmm, shouldn't this have a NEWS entry? -- Kalle Sommer Nielsen -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
2008/11/22 Kalle Sommer Nielsen [EMAIL PROTECTED]: 2008/11/22 David Coallier [EMAIL PROTECTED]: davidc Sat Nov 22 14:19:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_007.phpt pqueue_003.phpt Log: - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap-key() - Adjusted the tests Hmm, shouldn't this have a NEWS entry? Jaysus give me a second I had to go to the toilet (did you really need to know this?) :D Hehe yes it belongs in the news -- Slan, David -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
2008/11/22 David Coallier [EMAIL PROTECTED]: 2008/11/22 Kalle Sommer Nielsen [EMAIL PROTECTED]: 2008/11/22 David Coallier [EMAIL PROTECTED]: davidc Sat Nov 22 14:19:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_007.phpt pqueue_003.phpt Log: - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap-key() - Adjusted the tests Hmm, shouldn't this have a NEWS entry? Jaysus give me a second I had to go to the toilet (did you really need to know this?) :D hehe Hehe yes it belongs in the news Just so it doesn't be forgotten :) -- Kalle Sommer Nielsen -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
Hello Kalle, Saturday, November 22, 2008, 3:25:05 PM, you wrote: 2008/11/22 David Coallier [EMAIL PROTECTED]: davidc Sat Nov 22 14:19:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_007.phpt pqueue_003.phpt Log: - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap-key() - Adjusted the tests Hmm, shouldn't this have a NEWS entry? Since when do we add NEWS entries that fix stuff that was never released? David, please revert that entry. Otherwise it is hard to drop those entries prior to releasing. Best regards, Marcus -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
Hmm, shouldn't this have a NEWS entry? Since when do we add NEWS entries that fix stuff that was never released? David, please revert that entry. Otherwise it is hard to drop those entries prior to releasing. Done. -- Slan, David -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_007.phpt pqueue_003.phpt
On Sat, Nov 22, 2008 at 11:48 PM, Marcus Boerger [EMAIL PROTECTED] wrote: Hello Kalle, Saturday, November 22, 2008, 3:25:05 PM, you wrote: 2008/11/22 David Coallier [EMAIL PROTECTED]: davidc Sat Nov 22 14:19:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_007.phpt pqueue_003.phpt Log: - MFH - Bug #46615 - Return the count - 1 when invoking SplHeap-key() - Adjusted the tests Hmm, shouldn't this have a NEWS entry? Since when do we add NEWS entries that fix stuff that was never released? We do add stuff that has been fixed between two releases, even RC or alpha. These entries are then merged into a single one before the final release. See the release howto in the wiki. Cheers, -- Pierre http://blog.thepimp.net | http://www.libgd.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c
colder Sun Aug 3 18:16:10 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c Log: MFH: Remove cast and fix mem errors http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.1.2.6r2=1.1.2.7diff_format=u Index: php-src/ext/spl/spl_heap.c diff -u php-src/ext/spl/spl_heap.c:1.1.2.6 php-src/ext/spl/spl_heap.c:1.1.2.7 --- php-src/ext/spl/spl_heap.c:1.1.2.6 Sun Jul 6 23:45:55 2008 +++ php-src/ext/spl/spl_heap.c Sun Aug 3 18:16:10 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_heap.c,v 1.1.2.6 2008/07/06 23:45:55 colder Exp $ */ +/* $Id: spl_heap.c,v 1.1.2.7 2008/08/03 18:16:10 colder Exp $ */ #ifdef HAVE_CONFIG_H # include config.h @@ -227,7 +227,7 @@ heap-dtor = dtor; heap-ctor = ctor; heap-cmp = cmp; - heap-elements = (void **) safe_emalloc(sizeof(spl_ptr_heap_element), PTR_HEAP_BLOCK_SIZE, 0); + heap-elements = safe_emalloc(sizeof(spl_ptr_heap_element), PTR_HEAP_BLOCK_SIZE, 0); heap-max_size = PTR_HEAP_BLOCK_SIZE; heap-count= 0; heap-flags= 0; @@ -323,7 +323,7 @@ heap-count= from-count; heap-flags= from-flags; - heap-elements = (void **) safe_emalloc(sizeof(spl_ptr_heap_element),from-max_size,0); + heap-elements = safe_emalloc(sizeof(spl_ptr_heap_element),from-max_size,0); memcpy(heap-elements, from-elements, sizeof(spl_ptr_heap_element)*from-max_size); for (i=0; i heap-count; ++i) { @@ -383,6 +383,7 @@ intinherited = 0; intern = ecalloc(1, sizeof(spl_heap_object)); + *obj = intern; ALLOC_INIT_ZVAL(intern-retval); zend_object_std_init(intern-std, class_type TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c /ext/spl/tests heap_001.phpt heap_011.phpt
colder Sun Aug 3 19:07:31 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/spl/tests heap_011.phpt Modified files: /php-src/ext/splspl_heap.c /php-src/ext/spl/tests heap_001.phpt Log: MFH: Fix clone + add tests http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.1.2.7r2=1.1.2.8diff_format=u Index: php-src/ext/spl/spl_heap.c diff -u php-src/ext/spl/spl_heap.c:1.1.2.7 php-src/ext/spl/spl_heap.c:1.1.2.8 --- php-src/ext/spl/spl_heap.c:1.1.2.7 Sun Aug 3 18:16:10 2008 +++ php-src/ext/spl/spl_heap.c Sun Aug 3 19:07:31 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_heap.c,v 1.1.2.7 2008/08/03 18:16:10 colder Exp $ */ +/* $Id: spl_heap.c,v 1.1.2.8 2008/08/03 19:07:31 colder Exp $ */ #ifdef HAVE_CONFIG_H # include config.h @@ -397,7 +397,13 @@ intern-ce_get_iterator = other-ce_get_iterator; if (clone_orig) { + int i; intern-heap = spl_ptr_heap_clone(other-heap TSRMLS_CC); + for (i = 0; i intern-heap-count; ++i) { + if (intern-heap-elements[i]) { + Z_ADDREF_P((zval *)intern-heap-elements[i]); + } + } } else { intern-heap = other-heap; } http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/heap_001.phpt?r1=1.1.2.3r2=1.1.2.4diff_format=u Index: php-src/ext/spl/tests/heap_001.phpt diff -u php-src/ext/spl/tests/heap_001.phpt:1.1.2.3 php-src/ext/spl/tests/heap_001.phpt:1.1.2.4 --- php-src/ext/spl/tests/heap_001.phpt:1.1.2.3 Sat May 24 14:10:44 2008 +++ php-src/ext/spl/tests/heap_001.phpt Sun Aug 3 19:07:31 2008 @@ -32,7 +32,9 @@ $h-insert($b); $b = 5; +$h2 = clone $h; echo $h-extract().\n; +echo $h2-extract().\n; ? ===DONE=== ?php exit(0); ? @@ -47,4 +49,5 @@ 0 -- 4 +4 ===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/heap_011.phpt?view=markuprev=1.1 Index: php-src/ext/spl/tests/heap_011.phpt +++ php-src/ext/spl/tests/heap_011.phpt --TEST-- SPL: SplHeap with overriden compare() --FILE-- ?php class SplMinHeap2 extends SplMinHeap { public function compare($a, $b) { return -parent::compare($a,$b); } } $h = new SplMinHeap2(); $h-insert(1); $h-insert(6); $h-insert(5); $h-insert(2); var_dump($h-top()); class SplMaxHeap2 extends SplMaxHeap { public function compare($a, $b) { return -parent::compare($a,$b); } } $h = new SplMaxHeap2(); $h-insert(1); $h-insert(6); $h-insert(5); $h-insert(2); var_dump($h-top()); ? --EXPECT-- int(6) int(1) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c
colder Sat May 24 14:38:04 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c Log: MFH: Also register the get_iterator handler for Max/Min Heap http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.1.2.4r2=1.1.2.5diff_format=u Index: php-src/ext/spl/spl_heap.c diff -u php-src/ext/spl/spl_heap.c:1.1.2.4 php-src/ext/spl/spl_heap.c:1.1.2.5 --- php-src/ext/spl/spl_heap.c:1.1.2.4 Fri Feb 29 09:26:01 2008 +++ php-src/ext/spl/spl_heap.c Sat May 24 14:38:04 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_heap.c,v 1.1.2.4 2008/02/29 09:26:01 colder Exp $ */ +/* $Id: spl_heap.c,v 1.1.2.5 2008/05/24 14:38:04 colder Exp $ */ #ifdef HAVE_CONFIG_H # include config.h @@ -1166,6 +1166,9 @@ REGISTER_SPL_SUB_CLASS_EX(SplMinHeap, SplHeap, spl_heap_object_new, spl_funcs_SplMinHeap); REGISTER_SPL_SUB_CLASS_EX(SplMaxHeap, SplHeap, spl_heap_object_new, spl_funcs_SplMaxHeap); + spl_ce_SplMaxHeap-get_iterator = spl_heap_get_iterator; + spl_ce_SplMinHeap-get_iterator = spl_heap_get_iterator; + REGISTER_SPL_STD_CLASS_EX(SplPriorityQueue, spl_heap_object_new, spl_funcs_SplPriorityQueue); memcpy(spl_handler_SplPriorityQueue, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c
colder Fri Feb 29 09:26:01 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c Log: MFH: Fix #44288 (Move declarations) http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.1.2.3r2=1.1.2.4diff_format=u Index: php-src/ext/spl/spl_heap.c diff -u php-src/ext/spl/spl_heap.c:1.1.2.3 php-src/ext/spl/spl_heap.c:1.1.2.4 --- php-src/ext/spl/spl_heap.c:1.1.2.3 Mon Feb 25 23:41:04 2008 +++ php-src/ext/spl/spl_heap.c Fri Feb 29 09:26:01 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_heap.c,v 1.1.2.3 2008/02/25 23:41:04 colder Exp $ */ +/* $Id: spl_heap.c,v 1.1.2.4 2008/02/29 09:26:01 colder Exp $ */ #ifdef HAVE_CONFIG_H # include config.h @@ -273,13 +273,15 @@ static spl_ptr_heap_element spl_ptr_heap_delete_top(spl_ptr_heap *heap, void *cmp_userdata TSRMLS_DC) { /* {{{ */ int i, j; const int limit = (heap-count-1)/2; + spl_ptr_heap_element top; + spl_ptr_heap_element bottom; if (heap-count == 0) { return NULL; } - spl_ptr_heap_element top= heap-elements[0]; - spl_ptr_heap_element bottom = heap-elements[--heap-count]; + top= heap-elements[0]; + bottom = heap-elements[--heap-count]; for( i = 0; i limit; i = j) { @@ -920,13 +922,14 @@ { zval *object = (zval*)((zend_user_iterator *)iter)-it.data; spl_heap_it *iterator = (spl_heap_it *)iter; + spl_ptr_heap_element elem; if (iterator-object-heap-flags SPL_HEAP_CORRUPTED) { zend_throw_exception(spl_ce_RuntimeException, Heap is corrupted, heap properties are no longer ensured., 0 TSRMLS_CC); return; } - spl_ptr_heap_element elem = spl_ptr_heap_delete_top(iterator-object-heap, object TSRMLS_CC); + elem = spl_ptr_heap_delete_top(iterator-object-heap, object TSRMLS_CC); if (elem != NULL) { zval_ptr_dtor((zval **)elem); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl spl_heap.c
colder Mon Feb 25 23:41:04 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splspl_heap.c Log: MFH: Fix folding http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.1.2.2r2=1.1.2.3diff_format=u Index: php-src/ext/spl/spl_heap.c diff -u php-src/ext/spl/spl_heap.c:1.1.2.2 php-src/ext/spl/spl_heap.c:1.1.2.3 --- php-src/ext/spl/spl_heap.c:1.1.2.2 Mon Feb 25 23:39:08 2008 +++ php-src/ext/spl/spl_heap.c Mon Feb 25 23:41:04 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spl_heap.c,v 1.1.2.2 2008/02/25 23:39:08 colder Exp $ */ +/* $Id: spl_heap.c,v 1.1.2.3 2008/02/25 23:41:04 colder Exp $ */ #ifdef HAVE_CONFIG_H # include config.h @@ -1181,6 +1181,8 @@ return SUCCESS; } +/* }}} */ + /* * Local variables: * tab-width: 4 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php