Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21873 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12964 invoked by uid 1010); 15 Feb 2006 21:52:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 12949 invoked from network); 15 Feb 2006 21:52:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2006 21:52:05 -0000 X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:60038] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 71/00-12436-382A3F34 for ; Wed, 15 Feb 2006 16:52:03 -0500 Received: from [192.168.1.3] (dslb-084-063-016-076.pools.arcor-ip.net [84.63.16.76]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 945BC35C1DC; Wed, 15 Feb 2006 22:52:00 +0100 (CET) Date: Wed, 15 Feb 2006 22:50:41 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1355657626.20060215225041@marcus-boerger.de> To: l0t3k Cc: internals@lists.php.net In-Reply-To: <49.81.03593.F1463F34@pb1.pair.com> References: <49.81.03593.F1463F34@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] C Level Iterators and Userland Classes From: helly@php.net (Marcus Boerger) Hello l0t3k, first of all your question does not make any sense to me whatsoever. Anyway looking at the code you seem to be using a c-level iterator manually instead of using it inside foreach() construct. The first thing i can see is that you use the iterator index while the source code (zend_interface.h) says: ulong index; /* private to fe_reset/fe_fetch opcodes */ Unil now noone tried to emulate this stuff so i am not sure whether this is correct or not. But one thing i can say is that your usage revealed an error in the engien code. Index is incremented to early. Which is fixed by now. The second thing is that you did not use the dtor() handler so you have a memory leak. Otherwise i cannot see anything wrong with your iterator usage. And the more i think over it you are probably right in using that index. To try to answer what i think you want to know: What ever object you use. If it implements Traversable or derived its zend_class_entry has a get_iterator function that gets you access to an iteator struct and the handler table. You should never touch the data member of that iterator struct and the handlers are documented. In your case there is no need to use handler invalidate_current(). hope this helps marcus Wednesday, February 15, 2006, 6:23:44 PM, you wrote: > A quick question about using iterators in C code: > If it sufficient to use the interface gotten from > zend_class_entry->get_iterator to handle userland classes which implement > Iterator ? > The attachment is part of code i'm using to do Unicode based collation. Will > this work for userland iterators as well ? > l0t3k Best regards, Marcus