MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / lcache_htable_init

Function lcache_htable_init

modules/cachedb_local/hash.c:41–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39void lcache_htable_remove_safe(osips_free_f free_f, str attr, lcache_entry_t** it);
40
41int lcache_htable_init(struct lcache_col *col)
42{
43 int i = 0, j;
44
45 col->col_htable = func_malloc(col->malloc, sizeof *col->col_htable);
46 if (!col->col_htable) {
47 LM_ERR("no more shm memory\n");
48 return -1;
49 }
50 memset(col->col_htable, 0, sizeof *col->col_htable);
51
52 col->col_htable->size = col->size;
53
54 col->col_htable->htable = func_malloc(col->malloc, col->col_htable->size *
55 sizeof(lcache_t));
56 if(col->col_htable->htable == NULL)
57 {
58 LM_ERR("no more shared memory\n");
59 func_free(col->free, col->col_htable);
60 return -1;
61 }
62 memset(col->col_htable->htable, 0, col->col_htable->size * sizeof(lcache_t));
63
64 for(i= 0; i< col->col_htable->size; i++)
65 {
66 if(lock_init(&col->col_htable->htable[i].lock)== 0)
67 {
68 LM_ERR("failed to initialize lock [%d]\n", i);
69 goto error;
70 }
71 }
72
73 return 0;
74
75error:
76 for(j = 0; j< i; j++)
77 {
78 lock_destroy(&col->col_htable->htable[j].lock);
79 }
80 func_free(col->free, col->col_htable->htable);
81 func_free(col->free, col->col_htable);
82 return -1;
83}
84
85void lcache_htable_destroy(lcache_htable_t *htable, osips_free_f free_f)
86{

Callers 1

mod_initFunction · 0.85

Calls 2

lock_initFunction · 0.85
lock_destroyFunction · 0.85

Tested by

no test coverage detected