php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #60759
Patch spl_dllist_clear revision 2012-01-15 22:37 UTC by dragoonis@php.net
Patch spl_dllist_reset revision 2012-01-15 03:26 UTC by dragoonis

Patch spl_dllist_reset for SPL related Bug #60759

Patch version 2012-01-15 03:26 UTC

Return to Bug #60759 | Download this patch
Patch Revisions:

Developer: dragoonis

Index: ext/spl/spl_dllist.c
===================================================================
--- ext/spl/spl_dllist.c	(revision 322310)
+++ ext/spl/spl_dllist.c	(working copy)
@@ -596,6 +596,29 @@
 }
 /* }}} */
 
+/* {{{ proto bool SplDoublyLinkedList::reset() U
+	  Reset the SplDoublyLinkedList datastructure */
+SPL_METHOD(SplDoublyLinkedList, reset)
+{
+
+        zval *tmp = NULL;
+        spl_dllist_object *intern;
+
+        if (zend_parse_parameters_none() == FAILURE) {	
+                return;
+        }
+
+        intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+        while (intern->llist->count > 0) {
+                tmp = (zval *)spl_ptr_llist_pop(intern->llist TSRMLS_CC);
+                zval_ptr_dtor(&tmp);
+        }
+
+        RETURN_TRUE;
+}
+/* }}} */
+
 /* {{{ proto mixed SplDoublyLinkedList::pop() U
 	   Pop an element out of the SplDoublyLinkedList */
 SPL_METHOD(SplDoublyLinkedList, pop)
@@ -1306,6 +1329,7 @@
 };
 
 static const zend_function_entry spl_funcs_SplDoublyLinkedList[] = {
+        SPL_ME(SplDoublyLinkedList, reset,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
 	SPL_ME(SplDoublyLinkedList, pop,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)
 	SPL_ME(SplDoublyLinkedList, shift,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
 	SPL_ME(SplDoublyLinkedList, push,            arginfo_dllist_push,            ZEND_ACC_PUBLIC)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 08:01:30 2024 UTC