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

Function __init_table_rwlock

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

Source from the content-addressed store, hash-verified

258#define _RWLOCK_UNLOCK acl_pthread_mutex_unlock
259
260static int __init_table_rwlock(ACL_HTABLE *table, int enable)
261{
262 const char *myname = "__init_table_rwlock";
263 char tbuf[256];
264 int ret;
265
266 if (enable && table->rwlock == NULL) {
267 if (table->slice) {
268 table->rwlock = acl_slice_pool_calloc(__FILE__, __LINE__,
269 table->slice, 1, sizeof(_RWLOCK_TYPE));
270 } else {
271 table->rwlock = acl_mycalloc(1, sizeof(_RWLOCK_TYPE));
272 }
273
274 if (table->rwlock == NULL) {
275 acl_msg_error("%s(%s): calloc error(%s)", __FILE__,
276 myname, acl_last_strerror(tbuf, sizeof(tbuf)));
277 return -1;
278 }
279
280 ret = _RWLOCK_INIT(table->rwlock, NULL);
281 if (ret) {
282 acl_msg_error("%s(%d): init rwlock error(%s)", __FILE__,
283 __LINE__, acl_strerror(ret, tbuf, sizeof(tbuf)));
284 if (table->slice) {
285 acl_slice_pool_free(__FILE__, __LINE__, table->rwlock);
286 } else {
287 acl_myfree(table->rwlock);
288 }
289 return -1;
290 }
291 } else if (!enable && table->rwlock) {
292 _RWLOCK_DESTROY(table->rwlock);
293 if (table->slice) {
294 acl_slice_pool_free(__FILE__, __LINE__, table->rwlock);
295 } else {
296 acl_myfree(table->rwlock);
297 }
298 table->rwlock = NULL;
299 }
300
301 return 0;
302}
303
304/* acl_htable_create - create initial hash table */
305

Callers 2

acl_htable_create3Function · 0.85
acl_htable_ctlFunction · 0.85

Calls 5

acl_slice_pool_callocFunction · 0.85
acl_msg_errorFunction · 0.85
acl_last_strerrorFunction · 0.85
acl_strerrorFunction · 0.85
acl_slice_pool_freeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…