[Libvir] [PATCH 2/6] Inactive domain support: new virHash APIs

Daniel P. Berrange berrange at redhat.com
Thu Nov 16 18:18:25 UTC 2006


On Wed, Nov 15, 2006 at 12:39:01PM -0500, Daniel Veillard wrote:
> 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 :-)

Comitted, with the addition of the logic to return the number of elements
iterated over.

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  -=| 




More information about the libvir-list mailing list