void (*free)(resource *); /* Freeing function */
void (*dump)(resource *); /* Dump to debug output */
resource *(*lookup)(resource *, unsigned long); /* Look up address (only for debugging) */
+ size_t (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */
};
+/* Estimate of system allocator overhead per item, for memory consumtion stats */
+#define ALLOC_OVERHEAD 8
+
/* Generic resource manipulation */
typedef struct pool pool;
pool *rp_new(pool *, char *); /* Create new pool */
void rfree(void *); /* Free single resource */
void rdump(void *); /* Dump to debug output */
+size_t rmemsize(void *res); /* Return size of memory used by the resource */
void rlookup(unsigned long); /* Look up address (only for debugging) */
+void rmove(void *, pool *); /* Move to a different pool */
void *ralloc(pool *, struct resclass *);
void *mb_alloc(pool *, unsigned size);
void *mb_allocz(pool *, unsigned size);
+void *mb_realloc(void *m, unsigned size);
void mb_free(void *);
/* Memory pools with linear allocation */
* outside resource manager and possibly sysdep code.
*/
+void buffer_realloc(void **buf, unsigned *size, unsigned need, unsigned item_size);
+
+
#ifdef HAVE_LIBDMALLOC
/*
* The standard dmalloc macros tend to produce lots of namespace
- * conflicts and we use only xmalloc and xfree, so we can define
- * the stubs ourselves.
+ * conflicts and we use only xmalloc, xrealloc and xfree, so we
+ * can define the stubs ourselves.
*/
#define DMALLOC_DISABLE
#include <dmalloc.h>
#define xmalloc(size) _xmalloc_leap(__FILE__, __LINE__, size)
+#define xrealloc(size) _xrealloc_leap(__FILE__, __LINE__, size)
#define xfree(ptr) _xfree_leap(__FILE__, __LINE__, ptr)
#else
/*
* the renaming.
*/
#define xmalloc bird_xmalloc
+#define xrealloc bird_xrealloc
void *xmalloc(unsigned);
+void *xrealloc(void *, unsigned);
#define xfree(x) free(x)
#endif
#endif
+