Lines Matching refs:htab

62 static void _hdelete(const char *key, struct hsearch_data *htab,
96 int hcreate_r(size_t nel, struct hsearch_data *htab)
99 if (htab == NULL) {
105 if (htab->table != NULL) {
115 htab->size = nel;
116 htab->filled = 0;
119 htab->table = (struct env_entry_node *)calloc(htab->size + 1,
121 if (htab->table == NULL) {
140 void hdestroy_r(struct hsearch_data *htab)
145 if (htab == NULL) {
151 for (i = 1; i <= htab->size; ++i) {
152 if (htab->table[i].used > 0) {
153 struct env_entry *ep = &htab->table[i].entry;
159 free(htab->table);
162 htab->table = NULL;
203 struct hsearch_data *htab)
208 for (idx = last_idx + 1; idx < htab->size; ++idx) {
209 if (htab->table[idx].used <= 0)
211 if (!strncmp(match, htab->table[idx].entry.key, key_len)) {
212 *retval = &htab->table[idx].entry;
239 struct hsearch_data *htab, int flag, unsigned int hval,
242 if (htab->table[idx].used == hval
243 && strcmp(item.key, htab->table[idx].entry.key) == 0) {
247 if (htab->change_ok != NULL && htab->change_ok(
248 &htab->table[idx].entry, item.data,
258 if (do_callback(&htab->table[idx].entry, item.key,
267 free(htab->table[idx].entry.data);
268 htab->table[idx].entry.data = strdup(item.data);
269 if (!htab->table[idx].entry.data) {
276 *retval = &htab->table[idx].entry;
284 struct env_entry **retval, struct hsearch_data *htab, int flag)
305 hval %= htab->size;
312 if (htab->table[idx].used) {
319 if (htab->table[idx].used == USED_DELETED)
322 ret = _compare_and_overwrite_entry(item, action, retval, htab,
331 hval2 = 1 + hval % (htab->size - 2);
339 idx = htab->size + idx - hval2;
350 if (htab->table[idx].used == USED_DELETED
356 htab, flag, hval, idx);
360 while (htab->table[idx].used != USED_FREE);
369 if (htab->filled == htab->size) {
382 htab->table[idx].used = hval;
383 htab->table[idx].entry.key = strdup(item.key);
384 htab->table[idx].entry.data = strdup(item.data);
385 if (!htab->table[idx].entry.key ||
386 !htab->table[idx].entry.data) {
392 ++htab->filled;
395 env_callback_init(&htab->table[idx].entry);
397 env_flags_init(&htab->table[idx].entry);
400 if (htab->change_ok != NULL && htab->change_ok(
401 &htab->table[idx].entry, item.data, env_op_create, flag)) {
404 _hdelete(item.key, htab, &htab->table[idx].entry, idx);
411 if (do_callback(&htab->table[idx].entry, item.key, item.data,
415 _hdelete(item.key, htab, &htab->table[idx].entry, idx);
422 *retval = &htab->table[idx].entry;
442 static void _hdelete(const char *key, struct hsearch_data *htab,
450 htab->table[idx].used = USED_DELETED;
452 --htab->filled;
455 int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
464 idx = hsearch_r(e, ENV_FIND, &ep, htab, 0);
471 if (htab->change_ok != NULL &&
472 htab->change_ok(ep, NULL, env_op_delete, flag)) {
480 if (do_callback(&htab->table[idx].entry, key, NULL,
488 _hdelete(key, htab, ep, idx);
602 ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
606 struct env_entry *list[htab->size];
612 if ((resp == NULL) || (htab == NULL)) {
617 debug("EXPORT table = %p, htab.size = %d, htab.filled = %d, size = %lu\n",
618 htab, htab->size, htab->filled, (ulong)size);
624 for (i = 1, n = 0, totlen = 0; i <= htab->size; ++i) {
626 if (htab->table[i].used > 0) {
627 struct env_entry *ep = &htab->table[i].entry;
792 int himport_r(struct hsearch_data *htab,
801 if (htab == NULL) {
826 debug("Destroy Hash Table: %p table = %p\n", htab,
827 htab->table);
828 if (htab->table)
829 hdestroy_r(htab);
850 if (!htab->table) {
858 if (hcreate_r(nent, htab) == 0) {
912 if (hdelete_r(name, htab, flag))
943 hsearch_r(e, ENV_ENTER, &rv, htab, flag);
952 htab, htab->filled, htab->size,
974 if (hdelete_r(localvars[i], htab, flag))
993 int hwalk_r(struct hsearch_data *htab, int (*callback)(struct env_entry *entry))
998 for (i = 1; i <= htab->size; ++i) {
999 if (htab->table[i].used > 0) {
1000 retval = callback(&htab->table[i].entry);