On 11/16/2011 07:32 PM, Eric Blake wrote:
On 10/26/2011 05:36 AM, Stefan Berger wrote:
> Add a function to the virHashTable for getting an array of the hash table's
> keys and have the keys (optionally) sorted.
>
> Signed-off-by: Stefan Berger<stefanb(a)linux.vnet.ibm.com>
>
> ---
> src/libvirt_private.syms | 3 +
> src/util/hash.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++
> src/util/hash.h | 14 ++++++
> 3 files changed, 115 insertions(+)
Reordering for review purposes:
> Index: libvirt-acl/src/util/hash.h
> ===================================================================
> --- libvirt-acl.orig/src/util/hash.h
> +++ libvirt-acl/src/util/hash.h
> @@ -130,6 +130,20 @@ void *virHashLookup(virHashTablePtr tabl
> */
> void *virHashSteal(virHashTablePtr table, const void *name);
>
> +/*
> + * Get the set of keys and have them optionally sorted.
> + */
> +typedef struct _virHashKeyValuePair virHashKeyValuePair;
> +typedef virHashKeyValuePair *virHashKeyValuePairPtr;
> +struct _virHashKeyValuePair {
> + void *key;
Why isn't this 'const void *key'?
My bad.
I converted everything. It now looks like this.
*
* Get the set of keys and have them optionally sorted.
*/
typedef struct _virHashKeyValuePair virHashKeyValuePair;
typedef virHashKeyValuePair *virHashKeyValuePairPtr;
struct _virHashKeyValuePair {
const void *key;
const void *value;
};
typedef int (*virHashKeyComparator)(const virHashKeyValuePairPtr ,
const virHashKeyValuePairPtr );
virHashKeyValuePairPtr virHashGetItems(virHashTablePtr table,
virHashKeyComparator compar);
I hope this addresses your concerns. I do need the sorting and left it
in there without
wanting to either wrap it or offload it into the caller - if that's ok.
Stefan