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

Function acl_htable_create3

lib_acl/src/stdlib/common/acl_htable.c:311–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311ACL_HTABLE *acl_htable_create3(int size, unsigned int flag, ACL_SLICE_POOL *slice)
312{
313 ACL_HTABLE *table;
314 int ret;
315
316 if (slice) {
317 table = (ACL_HTABLE *) acl_slice_pool_calloc(__FILE__, __LINE__,
318 slice, 1, sizeof(ACL_HTABLE));
319 if (table == NULL) {
320 return NULL;
321 }
322 table->slice = slice;
323 } else {
324 table = (ACL_HTABLE *) acl_mycalloc(1, sizeof(ACL_HTABLE));
325 if (table == NULL) {
326 return NULL;
327 }
328 table->slice = NULL;
329 }
330
331 table->init_size = size;
332 table->flag = flag;
333
334 ret = htable_size(table, size < 13 ? 13 : size);
335 if(ret < 0) {
336 if (table->slice) {
337 acl_slice_pool_free(__FILE__, __LINE__, table);
338 } else {
339 acl_myfree(table);
340 }
341 return(NULL);
342 }
343
344 table->hash_fn = __def_hash_fn;
345
346 table->iter_head = htable_iter_head;
347 table->iter_next = htable_iter_next;
348 table->iter_tail = htable_iter_tail;
349 table->iter_prev = htable_iter_prev;
350 table->iter_info = htable_iter_info;
351
352 if ((flag & ACL_HTABLE_FLAG_USE_LOCK)) {
353 ret = __init_table_rwlock(table, 1);
354 if (ret < 0) {
355 if (table->slice) {
356 acl_slice_pool_free(__FILE__, __LINE__, table);
357 } else {
358 acl_myfree(table);
359 }
360 return NULL;
361 }
362 } else {
363 table->rwlock = NULL;
364 }
365
366 return table;
367}
368

Callers 2

htable_iterFunction · 0.85
acl_htable_createFunction · 0.85

Calls 4

acl_slice_pool_callocFunction · 0.85
acl_slice_pool_freeFunction · 0.85
__init_table_rwlockFunction · 0.85
htable_sizeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…