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

Function htable_iter2

lib_acl/samples/iterator/main.c:115–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115static void htable_iter2(void)
116{
117 ACL_HTABLE *table = acl_htable_create(10, 0);
118 ACL_ITER iter;
119 char key[32], *value;
120 int i;
121
122 for (i = 0; i < 20; i++) {
123 snprintf(key, sizeof(key), "key: %d", i);
124 value = acl_mymalloc(32);
125 snprintf(value, 32, "value: %d", i);
126 assert(acl_htable_enter(table, key, value));
127 }
128
129 i = 0;
130 printf("\n>>>acl_foreach for htable:\n");
131 acl_foreach(iter, table) {
132 printf("hash i=%d, [%s]\n", iter.i, (char*) iter.data);
133 i++;
134 }
135
136 printf(">>>total: %d\n", i);
137
138 i = 0;
139 printf("\n>>>acl_foreach_reverse for htable:\n");
140 acl_foreach_reverse(iter, table) {
141 printf("hash i=%d, [%s]\n", iter.i, (char*) iter.data);
142 i++;
143 }
144
145 printf(">>>total: %d\n", i);
146 acl_htable_free(table, acl_myfree_fn);
147}
148
149static void binhash_iter2(void)
150{

Callers 1

mainFunction · 0.85

Calls 4

acl_htable_createFunction · 0.85
acl_htable_enterFunction · 0.85
acl_htable_freeFunction · 0.85
acl_foreachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…