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

Function memPoolAlloc

lib_acl/src/stdlib/memory/squid_allocator.c:218–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216#endif
217
218static void *memPoolAlloc(const char *filename, int line,
219 ACL_ALLOCATOR *allocator, ACL_MEM_POOL * pool)
220{
221 SQUID_MEM_ALLOCATOR *squid_allocator =
222 (SQUID_MEM_ALLOCATOR *) allocator;
223 MemPool *squid_pool = (MemPool *) pool;
224 void *obj;
225
226 memMeterInc(squid_pool->meter.inuse);
227 gb_inc(&squid_pool->meter.total, 1);
228 gb_inc(&squid_allocator->TheMeter.total, pool->obj_size);
229 memMeterAdd(squid_allocator->TheMeter.inuse, pool->obj_size);
230 gb_inc(&squid_allocator->mem_traffic_volume, pool->obj_size);
231 allocator->mem_pool_alloc_calls++;
232
233 if (acl_stack_size(pool->pstack) > 0) {
234 acl_assert(squid_pool->meter.idle.level);
235 memMeterDec(squid_pool->meter.idle);
236 memMeterDel(squid_allocator->TheMeter.idle, pool->obj_size);
237 gb_inc(&squid_pool->meter.saved, 1);
238 gb_inc(&squid_allocator->TheMeter.saved, pool->obj_size);
239 obj = acl_stack_pop(pool->pstack);
240
241#if DEBUG_MEMPOOL
242 (void) VALGRIND_MAKE_READABLE(obj, pool->real_obj_size
243 + sizeof(struct mempool_cookie));
244#else
245 (void) VALGRIND_MAKE_READABLE(obj, pool->obj_size);
246#endif
247#if DEBUG_MEMPOOL
248 {
249 struct mempool_cookie *cookie = (void *)
250 (((unsigned char *) obj) + pool->real_obj_size);
251 acl_assert(cookie->cookie == MEMPOOL_COOKIE(obj));
252 acl_assert(cookie->pool == pool);
253 (void) VALGRIND_MAKE_NOACCESS(cookie, sizeof(cookie));
254 }
255#endif
256 } else {
257 acl_assert(!squid_pool->meter.idle.level);
258 memMeterInc(squid_pool->meter.alloc);
259 memMeterAdd(squid_allocator->TheMeter.alloc, pool->obj_size);
260#if DEBUG_MEMPOOL
261 {
262 struct mempool_cookie *cookie;
263 obj = acl_default_malloc(filename, line,
264 pool->real_obj_size
265 + sizeof(struct mempool_cookie));
266 cookie = (struct mempool_cookie *)
267 (((unsigned char *) obj) + pool->real_obj_size);
268 cookie->cookie = MEMPOOL_COOKIE(obj);
269 cookie->pool = pool;
270 (void) VALGRIND_MAKE_NOACCESS(cookie, sizeof(cookie));
271 }
272#else
273 obj = acl_default_malloc(filename, line, pool->obj_size);
274#endif
275 }

Callers

nothing calls this directly

Calls 3

acl_stack_sizeFunction · 0.85
acl_stack_popFunction · 0.85
acl_default_mallocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…