[Libvir] [Patch 2/4]: Xen inactive domains: hash file

The management of inactive domains uses the hashtable APIs for managing its list of config files. In doing so it needed some extra capabilities. This patch adds 3 new routines: - virHashForEach - iterate over all values in the hashtable invoking a callback for each one. Modifying the hashtable from the callback is forbidden, or bad stuff will happen. - virHashRemoteSet - iterate over all values in the hashtable invoking a callback for each one. If the callback returns non zero, the element will be removed. - virHashSearch - iterate over all values in the hashtable invoking a callback for each one. The first entry for which the callback returnbs non-zero will be returned. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Mon, Sep 04, 2006 at 01:33:01AM +0100, Daniel P. Berrange wrote:
The management of inactive domains uses the hashtable APIs for managing its list of config files. In doing so it needed some extra capabilities. This patch adds 3 new routines:
- virHashForEach - iterate over all values in the hashtable invoking a callback for each one. Modifying the hashtable from the callback is forbidden, or bad stuff will happen.
- virHashRemoteSet - iterate over all values in the hashtable invoking a callback for each one. If the callback returns non zero, the element will be removed.
Okay, I was suprized by the name virHashRemoteSet but it's actually virHashRemoveSet so it all make sense.
- virHashSearch - iterate over all values in the hashtable invoking a callback for each one. The first entry for which the callback returnbs non-zero will be returned.
I don't know if I should be pedantice about the presence of the function comments, on one hand it may feel like a tedious routine at time but I still like having those for long term maintenance. If needed I will just add them myself when I have recovered my brain ( okay I open the door wide to smart criticism:-) Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Mon, Sep 04, 2006 at 05:15:20AM -0400, Daniel Veillard wrote:
On Mon, Sep 04, 2006 at 01:33:01AM +0100, Daniel P. Berrange wrote:
The management of inactive domains uses the hashtable APIs for managing its list of config files. In doing so it needed some extra capabilities. This patch adds 3 new routines:
- virHashForEach - iterate over all values in the hashtable invoking a callback for each one. Modifying the hashtable from the callback is forbidden, or bad stuff will happen.
- virHashRemoteSet - iterate over all values in the hashtable invoking a callback for each one. If the callback returns non zero, the element will be removed.
Okay, I was suprized by the name virHashRemoteSet but it's actually virHashRemoveSet so it all make sense.
Doh, another typo !
- virHashSearch - iterate over all values in the hashtable invoking a callback for each one. The first entry for which the callback returnbs non-zero will be returned.
I don't know if I should be pedantice about the presence of the function comments, on one hand it may feel like a tedious routine at time but I still like having those for long term maintenance. If needed I will just add them myself when I have recovered my brain ( okay I open the door wide to smart criticism:-)
Yes, do be pedantic - I was being lazy by not writing comments. I'll add the comments before committing these methods. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard