+/* This pointer is in a pool. Find which one. */
+static struct at_pool_contents *find_pool(const void *ptr)
+{
+ struct at_pool_contents *p;
+
+ list_for_each(&pools, p, list) {
+ /* Special case for initial allocation: ptr *is* pool */
+ if (ptr == p->atp)
+ return p;
+
+ if ((char *)ptr >= (char *)p->pool
+ && (char *)ptr < (char *)p->pool + p->poolsize)
+ return p;
+ }
+ abort();
+}
+
+static int destroy_pool(struct at_pool_contents *p)
+{
+ list_del(&p->list);
+ munmap(p->pool, p->poolsize);
+ close(p->fd);
+ close(p->parent_rfd);
+ close(p->parent_wfd);
+ return 0;
+}
+