Re: [PATCH V4 01/10] Extend virHashTable with function to get hash tables keys

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

 



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@xxxxxxxxxxxxxxxxxx>

---
  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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]