[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



On 02/22/2011 10:54 AM, Daniel P. Berrange wrote:
> Relax the restriction that the hash table key must be a string
> by allowing an arbitrary hash code generator + comparison func
> to be provided
> 
> * util/hash.c, util/hash.h: Allow any pointer as a key
> * internal.h: Include stdbool.h as standard.
> * conf/domain_conf.c, conf/domain_conf.c,
>   conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
>   nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
>   qemu/qemu_command.c, qemu/qemu_driver.c,
>   qemu/qemu_process.c, uml/uml_driver.c,
>   xen/xm_internal.c: s/char */void */ in hash callbacks

> +++ b/src/internal.h
> @@ -8,6 +8,7 @@
>  # include <errno.h>
>  # include <limits.h>
>  # include <verify.h>
> +# include <stdbool.h>

Should we be scrubbing other files to remove includes rendered redundant
by including "internal.h"?

> +static bool virHashStrEqual(const void *namea, const void *nameb)
> +{
> +    return strcmp(namea, nameb) == 0 ? true : false;

cond == 0 ? true : false always looks like overkill to me (almost like
you were getting stumped by the 'make syntax-check' rules).  What's
wrong with:

return STREQ(namea, nameb);

> @@ -87,8 +110,9 @@ virHashComputeKey(virHashTablePtr table, const char *name)
>   *
>   * Returns the newly created object, or NULL if an error occured.
>   */
> -virHashTablePtr
> -virHashCreate(int size, virHashDeallocator deallocator)
> +virHashTablePtr virHashCreateFull(int size, virHashDeallocator deallocator,

Why the style change? I would have expected a newline between return
type and function name:

virHashTablePtr
virHashCreateFull(int size, ...

ACK with those nits addressed.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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