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

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



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 univention de
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.


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