scottmac                Wed Jun 17 12:57:39 2009 UTC

  Added files:                 
    /php-src/ext/spl/tests      dllist_010.phpt dllist_memleak.phpt 

  Modified files:              
    /php-src/ext/spl    spl_dllist.c 
  Log:
  Add SplDoublyLinkedList::prev(), no point in having a DLL that only goes one 
way
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_dllist.c?r1=1.20&r2=1.21&diff_format=u
Index: php-src/ext/spl/spl_dllist.c
diff -u php-src/ext/spl/spl_dllist.c:1.20 php-src/ext/spl/spl_dllist.c:1.21
--- php-src/ext/spl/spl_dllist.c:1.20   Thu Mar 26 20:02:12 2009
+++ php-src/ext/spl/spl_dllist.c        Wed Jun 17 12:57:38 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_dllist.c,v 1.20 2009/03/26 20:02:12 felipe Exp $ */
+/* $Id: spl_dllist.c,v 1.21 2009/06/17 12:57:38 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -350,6 +350,7 @@
        }
 
        spl_ptr_llist_destroy(intern->llist TSRMLS_CC);
+       SPL_LLIST_CHECK_DELREF(intern->traverse_pointer);
        zval_ptr_dtor(&intern->retval);
 
        efree(object);
@@ -1033,6 +1034,16 @@
 }
 /* }}} */
 
+/* {{{ proto void SplDoublyLinkedList::prev() U
+   Move to next entry */
+SPL_METHOD(SplDoublyLinkedList, prev)
+{
+       spl_dllist_object *intern = 
(spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+       spl_dllist_it_helper_move_forward(&intern->traverse_pointer, 
&intern->traverse_position, intern->llist, intern->flags ^ SPL_DLLIST_IT_LIFO 
TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ proto void SplDoublyLinkedList::next() U
    Move to next entry */
 SPL_METHOD(SplDoublyLinkedList, next)
@@ -1161,6 +1172,7 @@
        SPL_ME(SplDoublyLinkedList, current,         NULL,                      
     ZEND_ACC_PUBLIC)
        SPL_ME(SplDoublyLinkedList, key,             NULL,                      
     ZEND_ACC_PUBLIC)
        SPL_ME(SplDoublyLinkedList, next,            NULL,                      
     ZEND_ACC_PUBLIC)
+       SPL_ME(SplDoublyLinkedList, prev,            NULL,                      
     ZEND_ACC_PUBLIC)
        SPL_ME(SplDoublyLinkedList, valid,           NULL,                      
     ZEND_ACC_PUBLIC)
        {NULL, NULL, NULL}
 };

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/dllist_010.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/dllist_010.phpt
+++ php-src/ext/spl/tests/dllist_010.phpt
--TEST--
SPL: DoublyLinkedList: prev
--FILE--
<?php
$dll = new SplDoublyLinkedList();
$dll->push(1);
$dll->push(2);
$dll->push(3);
$dll->push(4);


$dll->rewind();
echo $dll->current()."\n";
$dll->next();
$dll->next();
echo $dll->current()."\n";
$dll->prev();
echo $dll->current()."\n";

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
1
3
2
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/dllist_memleak.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/dllist_memleak.phpt
+++ php-src/ext/spl/tests/dllist_memleak.phpt
--TEST--
SPL: DoublyLinkedList: memory leak when iterator pointer isn't at the last 
element
--FILE--
<?php
$dll = new SplDoublyLinkedList();
$dll->push(1);
$dll->push(2);
$dll->push(3);
$dll->push(4);


$dll->rewind();
echo $dll->current()."\n";
$dll->next();
$dll->next();
echo $dll->current()."\n";

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
1
3
===DONE===



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to