]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - lib/resource.h
Merge remote-tracking branch 'origin/master' into mq-filter-stack
[thirdparty/bird.git] / lib / resource.h
index 1a0568b48b72b4317504c87da707028e790cbd53..ad17d9ed45be5da41017935639124ae988c838bd 100644 (file)
@@ -59,11 +59,23 @@ void mb_free(void *);
 
 typedef struct linpool linpool;
 
+typedef struct lp_state {
+  void *current, *large;
+  byte *ptr;
+} lp_state;
+
 linpool *lp_new(pool *, unsigned blk);
 void *lp_alloc(linpool *, unsigned size);      /* Aligned */
 void *lp_allocu(linpool *, unsigned size);     /* Unaligned */
 void *lp_allocz(linpool *, unsigned size);     /* With clear */
 void lp_flush(linpool *);                      /* Free everything, but leave linpool */
+void lp_save(linpool *m, lp_state *p);         /* Save state */
+void lp_restore(linpool *m, lp_state *p);      /* Restore state */
+
+extern const int lp_chunk_size;
+#define LP_GAS             1024
+#define LP_GOOD_SIZE(x)            (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size)
+#define lp_new_default(p)   lp_new(p, LP_GOOD_SIZE(LP_GAS*4))
 
 /* Slabs */
 
@@ -89,9 +101,13 @@ void buffer_realloc(void **buf, unsigned *size, unsigned need, unsigned item_siz
  */
 #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)
+#define xmalloc(size) \
+  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 1)
+#define xrealloc(ptr, size) \
+  dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 1)
+#define xfree(ptr) \
+  dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE)
+
 #else
 /*
  * Unfortunately, several libraries we might want to link to define