[libvirt] [PATCH] hash: add common utility functions

Peter Krempa pkrempa at redhat.com
Mon Apr 7 09:23:19 UTC 2014


On 04/05/14 01:49, Eric Blake wrote:
> I almost wrote a hash value free function that just called
> VIR_FREE, then realized I couldn't be the first person to
> do that.  Sure enough, it was worth factoring into a common
> helper routine.
> 
> Furthermore, in a few places we were passing raw free() as
> the cleanup function; whereas going through VIR_FREE() ensures
> that any (temporary) tracing or other memory stress testing
> that we add to viralloc.c will not be bypassed.
> 
> * src/util/virhash.h (virHashValueFree): New function.
> * src/util/virhash.c (virHashValueFree): Implement it.
> * src/util/virobject.h (virObjectFreeHashData): New function.
> * src/libvirt_private.syms (virhash.h, virobject.h): Export them.
> * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnInit): Use
> common function.
> * src/qemu/qemu_capabilities.c (virQEMUCapsCacheNew): Likewise.
> * src/qemu/qemu_command.c (qemuDomainCCWAddressSetCreate):
> Likewise.
> * src/qemu/qemu_monitor.c (qemuMonitorGetBlockInfo): Likewise.
> * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
> * src/util/virclosecallbacks.c (virCloseCallbacksNew): Likewise.
> * src/util/virkeyfile.c (virKeyFileParseGroup): Likewise.
> * tests/qemumonitorjsontest.c
> (testQemuMonitorJSONqemuMonitorJSONGetBlockInfo): Likewise.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
> 
> It turns out I may end up not using the common helper in my
> code after all, but the cleanup is still worth posting.
> 
>  src/libvirt_private.syms            |  2 ++
>  src/nwfilter/nwfilter_learnipaddr.c |  9 +--------
>  src/qemu/qemu_capabilities.c        |  9 +--------
>  src/qemu/qemu_command.c             |  8 +-------
>  src/qemu/qemu_monitor.c             |  2 +-
>  src/qemu/qemu_process.c             |  6 +-----
>  src/util/virclosecallbacks.c        | 11 ++---------
>  src/util/virhash.c                  |  9 ++++++++-
>  src/util/virhash.h                  |  5 ++++-
>  src/util/virkeyfile.c               |  9 ++-------
>  src/util/virobject.c                | 17 ++++++++++++++++-
>  src/util/virobject.h                |  3 ++-
>  tests/qemumonitorjsontest.c         |  6 +++---
>  13 files changed, 44 insertions(+), 52 deletions(-)

ACK,

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140407/c95b82d1/attachment-0001.sig>


More information about the libvir-list mailing list