[libvirt] [libvirt-glib] Prefer 'for' over 'while'
Philipp Hahn
hahn at univention.de
Thu Jan 26 07:18:38 UTC 2012
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 at 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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120126/ca2a7b0d/attachment-0001.sig>
More information about the libvir-list
mailing list