[Libvir] [PATCH 2/6] Inactive domain support: new virHash APIs
Daniel Veillard
veillard at redhat.com
Wed Nov 15 17:39:01 UTC 2006
On Wed, Nov 15, 2006 at 04:25:55PM +0000, Daniel P. Berrange wrote:
> On Wed, Nov 15, 2006 at 04:50:55AM -0500, Daniel Veillard wrote:
> > On Wed, Nov 15, 2006 at 02:18:48AM +0000, Daniel P. Berrange wrote:
> > > The attached patch adds a couple of new APIs to the hash table object to
> > > allow various different ways of iterating over the contents of the hash
> > > table. The methods are:
> > >
> > > virHashForEach
> > > virHashRemoveSet
> > > virHashSearch
> > >
> > > Docs for these methods are all inline. Compared to previous patch a logic
> > > flaw in the virHashRemoveSet method was fixed prevently some severe memory
> > > corruption!
> >
> > The APIs are okay, I'm just wondering if the iterator should not return
> > an int allowing to break the iteration, but admitedly that would make it
> > close to the search. So it's fine as-is.
>
> Yes, that's a good idea - I'll make it return number of elements - I think
> I could acutaly make use of that elsewhere already.
>
> > > + int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDeallocator f, const void *data) {
> > > + int i;
> > > +
> > > + }
> >
> > Iterating when removing entries which are first in the list is a bit tricky
> > but that's looks fine.
>
> Yeah, that's why i wrote a dedicated method for iterating & removing in
> one go - calling 'virHashRemove' from the normal iterator just caused
> very bad things to happen :-)
Compute next first, then process to test, usually that works :-)
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
More information about the libvir-list
mailing list