]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
hashtable: add get_size method
authorRay Strode <rstrode@redhat.com>
Sun, 1 Dec 2013 23:58:02 +0000 (18:58 -0500)
committerRay Strode <rstrode@redhat.com>
Tue, 3 Dec 2013 15:51:32 +0000 (10:51 -0500)
Right now there's no easy way to know if a hash table is empty,
which I'm going to need in a future commit.

This commit adds a get_size method to return the number of items in
the hash table.

src/libply/ply-hashtable.c
src/libply/ply-hashtable.h

index 7d8d648e491b1293e2f0703d5ba459d4eaa35618..7f20a53432f0aa0e89ed057a2f54294838a4be39 100644 (file)
@@ -281,6 +281,11 @@ ply_hashtable_foreach (ply_hashtable_t              *hashtable,
     }
 }
 
+int
+ply_hashtable_get_size (ply_hashtable_t *hashtable)
+{
+  return hashtable->live_node_count;
+}
 
 #ifdef PLY_HASHTABLE_ENABLE_TEST
 #include <stdio.h>
index 016c781eea8dee92d5842c97dc6112027f0cd0fa..e7e1a6eb28abf32151fe5ba3c28952c7f117bd7d 100644 (file)
@@ -57,6 +57,8 @@ int ply_hashtable_lookup_full (ply_hashtable_t *hashtable,
 void ply_hashtable_foreach (ply_hashtable_t              *hashtable,
                                                        ply_hashtable_foreach_func_t  func,
                                                        void                         *user_data);
+
+int ply_hashtable_get_size (ply_hashtable_t *hashtable);
 #endif
 
 #endif /* PLY_HASHTABLE_H */