it should free all old mem and reset to an empty state.
struct alloc_pool *pool = (struct alloc_pool *)p;
struct pool_extent *cur, *prev, *next;
- if (!pool || !addr)
+ if (!pool)
return;
+ if (!addr) {
+ if (!pool->extents)
+ return;
+ addr = PTR_ADD(pool->extents->start, pool->extents->free);
+ }
+
for (prev = NULL, cur = pool->extents; cur; prev = cur, cur = cur->next) {
if (addr >= cur->start
&& addr < PTR_ADD(cur->start, pool->size))