From c8bf38e5fb717d40635a2a89b22ed71b0de4266b Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 1 Dec 2020 13:33:34 +0100 Subject: Squashed 'dependencies/uthash/' content from commit 8e67ced git-subtree-dir: dependencies/uthash git-subtree-split: 8e67ced1d1c5bd8141c542a22630e6de78aa6b90 --- doc/index.html | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 doc/index.html (limited to 'doc/index.html') diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 000000000..11b120e22 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,122 @@ + + + + + uthash: a hash table for C structures + + + + + +
+ GitHub page > + uthash home + + + +
+ +
+
+ + + +
+ Any C structure can be stored in a hash table using uthash. Just add a + UT_hash_handle to the structure and choose one or more fields + in your structure to act as the key. Then use these macros to store, + retrieve or delete items from the hash table. + +
+Example 1. Adding an item to a hash. +
+
+#include "uthash.h"
+
+struct my_struct {
+    int id;            /* we'll use this field as the key */
+    char name[10];
+    UT_hash_handle hh; /* makes this structure hashable */
+};
+
+struct my_struct *users = NULL;
+
+void add_user(struct my_struct *s) {
+    HASH_ADD_INT( users, id, s );
+}
+
+
+
+
+ +
+Example 2. Looking up an item in a hash. +
+
+struct my_struct *find_user(int user_id) {
+    struct my_struct *s;
+
+    HASH_FIND_INT( users, &user_id, s );
+    return s;
+}
+
+
+
+
+ +
+Example 3. Deleting an item from a hash. +
+ +
+void delete_user(struct my_struct *user) {
+    HASH_DEL( users, user);
+}
+
+
+
+
+ + For more information and examples, please see the User Guide. + +
+
+ +
+ + + + + + -- cgit v1.2.3