+/* Free a memory buffer */
+void sm_free_pool_memory(char *fname, int lineno, POOLMEM *obuf)
+{
+ struct abufhead *buf;
+ int pool;
+
+ ASSERT(obuf);
+ P(mutex);
+ buf = (struct abufhead *)((char *)obuf - HEAD_SIZE);
+ pool = buf->pool;
+ pool_ctl[pool].in_use--;
+ if (pool == 0) {
+ free((char *)buf); /* free nonpooled memory */
+ } else { /* otherwise link it to the free pool chain */
+#ifdef DEBUG
+ struct abufhead *next;
+ /* Don't let him free the same buffer twice */
+ for (next=pool_ctl[pool].free_buf; next; next=next->next) {
+ if (next == buf) {
+ Dmsg4(300, "bad free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
+ V(mutex); /* unblock the pool */
+ ASSERT(next != buf); /* attempt to free twice */
+ }
+ }
+#endif
+ buf->next = pool_ctl[pool].free_buf;
+ pool_ctl[pool].free_buf = buf;
+ }
+ Dmsg4(300, "free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
+ V(mutex);
+}
+
+