colder Sun Aug 3 19:07:22 2008 UTC
Added files:
/php-src/ext/spl/tests heap_011.phpt
Modified files:
/php-src/ext/spl spl_heap.c
/php-src/ext/spl/tests heap_001.phpt
Log:
Fix clone + add tests
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_heap.c?r1=1.8&r2=1.9&diff_format=u
Index: php-src/ext/spl/spl_heap.c
diff -u php-src/ext/spl/spl_heap.c:1.8 php-src/ext/spl/spl_heap.c:1.9
--- php-src/ext/spl/spl_heap.c:1.8 Sun Aug 3 18:15:18 2008
+++ php-src/ext/spl/spl_heap.c Sun Aug 3 19:07:21 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_heap.c,v 1.8 2008/08/03 18:15:18 colder Exp $ */
+/* $Id: spl_heap.c,v 1.9 2008/08/03 19:07:21 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.2&r2=1.3&diff_format=u
Index: php-src/ext/spl/tests/heap_001.phpt
diff -u php-src/ext/spl/tests/heap_001.phpt:1.2
php-src/ext/spl/tests/heap_001.phpt:1.3
--- php-src/ext/spl/tests/heap_001.phpt:1.2 Sat May 24 14:12:00 2008
+++ php-src/ext/spl/tests/heap_001.phpt Sun Aug 3 19:07:22 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=markup&rev=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