Lines Matching refs:tab
36 HashTab *tab = (HashTab *)calloc(1, sizeof(HashTab) + sizeof(HashNode*) * info->maxBucket);
37 INIT_ERROR_CHECK(tab != NULL, return -1, "Failed to create hash tab");
38 tab->maxBucket = info->maxBucket;
39 tab->keyHash = info->keyHash;
40 tab->nodeCompare = info->nodeCompare;
41 tab->keyCompare = info->keyCompare;
42 tab->nodeHash = info->nodeHash;
43 tab->nodeFree = info->nodeFree;
44 tab->tableId = g_tableId++;
45 *handle = (HashMapHandle)tab;
49 static HashNode *GetHashNodeByNode(const HashTab *tab, const HashNode *root, const HashNode *new)
53 int ret = tab->nodeCompare(node, new);
62 static HashNode *GetHashNodeByKey(const HashTab *tab, const HashNode *root, const void *key, HashKeyCompare keyCompare)
64 (void)tab;
80 HashTab *tab = (HashTab *)handle;
81 int hashCode = tab->nodeHash(node);
83 hashCode = hashCode % tab->maxBucket;
84 INIT_ERROR_CHECK(hashCode < tab->maxBucket, return -1, "Invalid hashcode %d %d", tab->maxBucket, hashCode);
87 HashNode *tmp = GetHashNodeByNode(tab, tab->buckets[hashCode], node);
92 node->next = tab->buckets[hashCode];
93 tab->buckets[hashCode] = node;
100 HashTab *tab = (HashTab *)handle;
101 int hashCode = tab->keyHash(key);
103 hashCode = hashCode % tab->maxBucket;
104 INIT_ERROR_CHECK(hashCode < tab->maxBucket, return, "Invalid hashcode %d %d", tab->maxBucket, hashCode);
106 HashNode *node = tab->buckets[hashCode];
109 int ret = tab->keyCompare(node, key);
111 if (node == tab->buckets[hashCode]) {
112 tab->buckets[hashCode] = node->next;
126 HashTab *tab = (HashTab *)handle;
127 int hashCode = tab->keyHash(key);
129 hashCode = hashCode % tab->maxBucket;
130 INIT_ERROR_CHECK(hashCode < tab->maxBucket, return NULL,
131 "Invalid hashcode %d %d", tab->maxBucket, hashCode);
132 return GetHashNodeByKey(tab, tab->buckets[hashCode], key, tab->keyCompare);
135 static void HashListFree(HashTab *tab, HashNode *root, void *context)
143 if (tab->nodeFree != NULL) {
144 tab->nodeFree(node, context);
153 HashTab *tab = (HashTab *)handle;
154 for (int i = 0; i < tab->maxBucket; i++) {
155 HashListFree(tab, tab->buckets[i], context);
157 free(tab);
165 HashTab *tab = (HashTab *)handle;
166 INIT_ERROR_CHECK((hashCode < tab->maxBucket) && (hashCode >= 0), return NULL,
167 "Invalid hash code %d %d", tab->maxBucket, hashCode);
168 return GetHashNodeByKey(tab, tab->buckets[hashCode], key, keyCompare);
175 HashTab *tab = (HashTab *)handle;
176 for (int i = 0; i < tab->maxBucket; i++) {
177 HashNode *node = tab->buckets[i];
189 HashTab *tab = (HashTab *)handle;
190 for (int i = 0; i < tab->maxBucket; i++) {
191 HashNode *node = tab->buckets[i];