Esempio n. 1
0
static inline void
smfree_batch(struct small_alloc *alloc)
{
	if (alloc->is_delayed_free_mode || lifo_is_empty(&alloc->delayed))
		return;

	const int BATCH = 100;

	for (int i = 0; i < BATCH; i++) {
		void *item = lifo_pop(&alloc->delayed);
		if (item == NULL)
			break;
		smfree(alloc, item);
	}
}
Esempio n. 2
0
static inline void
smfree_batch(struct small_alloc *alloc)
{
	if (alloc->is_delayed_free_mode || lifo_is_empty(&alloc->delayed))
		return;

	const int BATCH = 100;
	struct mempool *pool = lifo_peek(&alloc->delayed);

	for (int i = 0; i < BATCH; i++) {
		void *item = lifo_pop(&pool->delayed);
		if (item == NULL) {
			(void) lifo_pop(&alloc->delayed);
			pool = lifo_peek(&alloc->delayed);
			if (pool == NULL)
				break;
			continue;
		}
		mempool_free(pool, item);
	}
}