[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Allow hash tables to use generic pointers as keys



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

Attachment: pgpuwVnR2t0uW.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]