[libvirt] [PATCH] Allow hash tables to use generic pointers as keys
Christophe Fergeau
cfergeau at gmail.com
Wed Feb 23 21:35:01 UTC 2011
Hi,
On Tue, Feb 22, 2011 at 05:54:31PM +0000, Daniel P. Berrange wrote:
> +virHashTablePtr virHashCreateFull(int size, virHashDeallocator deallocator,
> + virHashCode code, virHashEqual equal,
> + virHashCopy copy, virHashRelease release)
I find the naming confusing/non obvious here, virHashDeallocator VS
virHashRelease, and virHashCopy is vague as to what it copies. What about
virHashKeyRelease (or Deallocator, or Free), virHashValueRelease and
virHashKeyCopy?
> {
> virHashTablePtr table = NULL;
>
> @@ -103,6 +127,10 @@ virHashCreate(int size, virHashDeallocator deallocator)
> table->size = size;
> table->nbElems = 0;
> table->f = deallocator;
"f" could be changed to a more obvious name now that there are different
function pointers in virHash, but that's not directly related to this
patch.
> + table->code = code;
> + table->equal = equal;
> + table->copy = copy;
> + table->release = release;
> diff --git a/src/util/hash.h b/src/util/hash.h
> index cf08e1a..6316fd9 100644
> --- a/src/util/hash.h
> +++ b/src/util/hash.h
> +typedef unsigned long (*virHashCode)(const void *name);
> +typedef bool (*virHashEqual)(const void *namea, const void *nameb);
> +typedef void *(*virHashCopy)(const void *name);
> +typedef void (*virHashRelease)(void *name);
Can these function pointers be documented, the others in this file
already have doc :)
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110223/a170e999/attachment-0001.sig>
More information about the libvir-list
mailing list