diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/flowspec_test.c | 4 | ||||
-rw-r--r-- | lib/mempool.c | 2 | ||||
-rw-r--r-- | lib/resource.h | 5 |
3 files changed, 9 insertions, 2 deletions
diff --git a/lib/flowspec_test.c b/lib/flowspec_test.c index 36336104..69bc279d 100644 --- a/lib/flowspec_test.c +++ b/lib/flowspec_test.c @@ -401,7 +401,7 @@ t_builder4(void) resource_init(); struct flow_builder *fb = flow_builder_init(&root_pool); - linpool *lp = lp_new(&root_pool, 4096); + linpool *lp = lp_new_default(&root_pool); /* Expectation */ @@ -482,7 +482,7 @@ t_builder6(void) net_addr_ip6 ip; resource_init(); - linpool *lp = lp_new(&root_pool, 4096); + linpool *lp = lp_new_default(&root_pool); struct flow_builder *fb = flow_builder_init(&root_pool); fb->ipv6 = 1; diff --git a/lib/mempool.c b/lib/mempool.c index a8281041..3cf9c2d3 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -32,6 +32,8 @@ struct lp_chunk { byte data[0]; }; +const int lp_chunk_size = sizeof(struct lp_chunk); + struct linpool { resource r; byte *ptr, *end; diff --git a/lib/resource.h b/lib/resource.h index 1a0568b4..761c6adc 100644 --- a/lib/resource.h +++ b/lib/resource.h @@ -65,6 +65,11 @@ void *lp_allocu(linpool *, unsigned size); /* Unaligned */ void *lp_allocz(linpool *, unsigned size); /* With clear */ void lp_flush(linpool *); /* Free everything, but leave linpool */ +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 */ typedef struct slab slab; |