Keep track of free dlechg structs

parent 966f8205
......@@ -147,7 +147,8 @@ dlechg_pool_fill(struct buddy_reqs *reqs, const void *priv)
struct fellow_dlechg_top {
unsigned magic;
#define FELLOW_DLECHG_TOP_MAGIC 0x710e71a2
buddy_t *buddy;
unsigned nfree; // mostly debug aid
buddy_t *buddy;
struct fellow_dlechg_head head;
VSLIST_HEAD(,fellow_dlechg) free;
struct dlechg_pool pool[1];
......@@ -160,8 +161,11 @@ fellow_dlechg_alloc(struct fellow_dlechg_top *fdct)
struct buddy_ptr_extent mem;
fdc = VSLIST_FIRST(&fdct->free);
if (fdc != NULL)
if (fdc != NULL) {
VSLIST_REMOVE_HEAD(&fdct->free, u.freelist);
AN(fdct->nfree);
fdct->nfree--;
}
else {
mem = buddy_get_next_ptr_extent(
dlechg_pool_get(fdct->pool, NULL));
......@@ -296,5 +300,6 @@ fellow_dlechg_get(struct fellow_dlechg_top *fdct, struct fellow_dle *e)
memset(fdc, 0, sizeof *fdc);
VSLIST_INSERT_HEAD(&fdct->free, fdc, u.freelist);
fdct->nfree++;
return (e);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment