MINOR: pools: prepare functions to override malloc/free in pools
This will be useful to add some debugging capabilities. For now it changes nothing.
This commit is contained in:
parent
424ecfb33c
commit
f13322ede1
|
@ -155,6 +155,23 @@ static inline void *pool_alloc_dirty(struct pool_head *pool)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* allocates an area of size <size> and returns it. The semantics are similar
|
||||||
|
* to those of malloc().
|
||||||
|
*/
|
||||||
|
static inline void *pool_alloc_area(size_t size)
|
||||||
|
{
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* frees an area <area> of size <size> allocated by pool_alloc_area(). The
|
||||||
|
* semantics are identical to free() except that the size is specified and
|
||||||
|
* may be ignored.
|
||||||
|
*/
|
||||||
|
static inline void pool_free_area(void *area, size_t __maybe_unused size)
|
||||||
|
{
|
||||||
|
free(area);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to type <type> taken from the pool <pool_type> or
|
* Returns a pointer to type <type> taken from the pool <pool_type> or
|
||||||
* dynamically allocated. In the first case, <pool_type> is updated to point to
|
* dynamically allocated. In the first case, <pool_type> is updated to point to
|
||||||
|
|
|
@ -117,7 +117,7 @@ void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail)
|
||||||
if (pool->limit && pool->allocated >= pool->limit)
|
if (pool->limit && pool->allocated >= pool->limit)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr = malloc(pool->size + POOL_EXTRA);
|
ptr = pool_alloc_area(pool->size + POOL_EXTRA);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
pool->failed++;
|
pool->failed++;
|
||||||
if (failed)
|
if (failed)
|
||||||
|
@ -163,7 +163,7 @@ void pool_flush2(struct pool_head *pool)
|
||||||
temp = next;
|
temp = next;
|
||||||
next = *POOL_LINK(pool, temp);
|
next = *POOL_LINK(pool, temp);
|
||||||
pool->allocated--;
|
pool->allocated--;
|
||||||
free(temp);
|
pool_free_area(temp, pool->size + POOL_EXTRA);
|
||||||
}
|
}
|
||||||
pool->free_list = next;
|
pool->free_list = next;
|
||||||
HA_SPIN_UNLOCK(POOL_LOCK, &pool->lock);
|
HA_SPIN_UNLOCK(POOL_LOCK, &pool->lock);
|
||||||
|
@ -199,7 +199,7 @@ void pool_gc2(struct pool_head *pool_ctx)
|
||||||
temp = next;
|
temp = next;
|
||||||
next = *POOL_LINK(entry, temp);
|
next = *POOL_LINK(entry, temp);
|
||||||
entry->allocated--;
|
entry->allocated--;
|
||||||
free(temp);
|
pool_free_area(temp, entry->size + POOL_EXTRA);
|
||||||
}
|
}
|
||||||
entry->free_list = next;
|
entry->free_list = next;
|
||||||
if (entry != pool_ctx)
|
if (entry != pool_ctx)
|
||||||
|
|
Loading…
Reference in New Issue