Re: [libvirt-glib] Prefer 'for' over 'while'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Thursday 26 January 2012 06:10:28 Zeeshan Ali (Khattak) wrote:
> -    it = node->children;
> -    while (it != NULL) {
> +    for (it = node->children; it != NULL; it = it->next) {
...
> -        xmlNodePtr next = it->next;
...
>          cont = iter_func(it, opaque);
...
> -        it = next;
Your changed version only has the same behaviour, if the user-passed-in 
function iter_func() never changes it->next, which you can't guarentee here. 
You need to keep the "next" copy.

BYtE
Philipp
-- 
Philipp Hahn           Open Source Software Engineer      hahn@xxxxxxxxxxxxx
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99
                                                   http://www.univention.de/

Attachment: signature.asc
Description: This is a digitally signed message part.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]