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

Function tls_mem_alloc

lib_acl/src/stdlib/memory/acl_mem_slice.c:309–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309static void *tls_mem_alloc(const char *filename, int line, size_t len)
310{
311 const char *myname = "tls_mem_alloc";
312 ACL_MEM_SLICE *mem_slice = acl_pthread_getspecific(__mem_slice_key);
313 char *ptr;
314 MBLOCK *real_ptr;
315
316 if (mem_slice == NULL) {
317 /* ÿ�����̻߳���Լ����ֲ߳̾��洢�ڴ�� */
318 mem_slice = mem_slice_create();
319 mem_slice->slice_list = __mem_slice_list;
320
321 /* �����̵߳��ֲ߳̾��洢�ڴ������ȫ���ڴ�ؾ�������� */
322 if (__mem_slice_list_lock)
323 thread_mutex_lock(__mem_slice_list_lock);
324 private_array_push(__mem_slice_list, mem_slice);
325 if (__mem_slice_list_lock)
326 thread_mutex_unlock(__mem_slice_list_lock);
327 }
328
329 {
330 int i;
331 for (i = 0; i < mem_slice->slice_pool->nslice; i++) {
332 printf("slice=%p\r\n", mem_slice->slice_pool->slices[i]);
333 }
334 }
335 real_ptr = (MBLOCK *) acl_slice_pool_alloc(filename, line,
336 mem_slice->slice_pool, SPACE_FOR(len));
337 if (real_ptr == 0) {
338 acl_msg_error("%s(%d): malloc: insufficient memory",
339 myname, __LINE__);
340 return 0;
341 }
342
343 mem_slice->nalloc++;
344 if (mem_slice->nalloc == mem_slice->nalloc_gc) {
345 mem_slice->nalloc = 0;
346 mem_slice_gc(mem_slice);
347 }
348 CHECK_OUT_PTR(ptr, real_ptr, mem_slice, len);
349 return ptr;
350}
351
352static void *tls_mem_calloc(const char *filename, int line, size_t nmemb, size_t size)
353{

Callers 5

tls_mem_callocFunction · 0.85
tls_mem_reallocFunction · 0.85
tls_mem_memdupFunction · 0.85
tls_mem_strdupFunction · 0.85
tls_mem_strndupFunction · 0.85

Calls 8

acl_pthread_getspecificFunction · 0.85
mem_slice_createFunction · 0.85
thread_mutex_lockFunction · 0.85
private_array_pushFunction · 0.85
thread_mutex_unlockFunction · 0.85
acl_slice_pool_allocFunction · 0.85
acl_msg_errorFunction · 0.85
mem_slice_gcFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…