MCPcopy Create free account
hub / github.com/acl-dev/acl / debug_htable_enter

Function debug_htable_enter

lib_acl/src/stdlib/debug/debug_htable.c:149–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147/* debug_htable_enter - enter (key, value) pair */
148
149DEBUG_HTABLE_INFO *debug_htable_enter(DEBUG_HTABLE *table, const char *key, char *value)
150{
151 DEBUG_HTABLE_INFO *ht;
152 int ret;
153 unsigned n;
154
155 n = table->hash_fn(key, strlen(key));
156
157 if (table->used >= table->size) {
158 ret = debug_htable_grow(table);
159 if(ret < 0) {
160 return(NULL);
161 }
162 }
163
164 n = n % table->size;
165
166 for (ht = table->data[n]; ht; ht = ht->next) {
167 if (STREQ(key, ht->key)) {
168 return (ht);
169 }
170 }
171
172 ht = (DEBUG_HTABLE_INFO *) MALLOC(sizeof(DEBUG_HTABLE_INFO));
173 if (ht == NULL) {
174 return(NULL);
175 }
176
177 ht->key = SANE_STRDUP(key);
178 if (ht->key == NULL) {
179 FREE(ht);
180 return(NULL);
181 }
182
183 ht->value = value;
184 debug_htable_link(table, ht, n);
185
186 return (ht);
187}
188
189/* debug_htable_find - lookup value */
190

Callers 6

acl_debug_mallocFunction · 0.85
acl_debug_callocFunction · 0.85
acl_debug_reallocFunction · 0.85
acl_debug_strdupFunction · 0.85
acl_debug_strndupFunction · 0.85
acl_debug_memdupFunction · 0.85

Calls 1

debug_htable_growFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…