diff --git a/include/common/hpack-tbl.h b/include/common/hpack-tbl.h index 44c0cc117..6d529f20f 100644 --- a/include/common/hpack-tbl.h +++ b/include/common/hpack-tbl.h @@ -136,6 +136,17 @@ enum { extern const struct http_hdr hpack_sht[HPACK_SHT_SIZE]; extern struct pool_head *pool_head_hpack_tbl; +/* when built outside of haproxy, HPACK_STANDALONE must be defined, and + * pool_head_hpack_tbl->size must be set to the DHT size. + */ +#ifndef HPACK_STANDALONE +#define hpack_alloc(pool) pool_alloc(pool) +#define hpack_free(pool, ptr) pool_free(pool, ptr) +#else +#define hpack_alloc(pool) malloc(pool->size) +#define hpack_free(pool, ptr) free(ptr) +#endif + extern int __hpack_dht_make_room(struct hpack_dht *dht, unsigned int needed); extern int hpack_dht_insert(struct hpack_dht *dht, struct ist name, struct ist value); @@ -243,7 +254,7 @@ static inline struct hpack_dht *hpack_dht_alloc() if (unlikely(!pool_head_hpack_tbl)) return NULL; - dht = pool_alloc(pool_head_hpack_tbl); + dht = hpack_alloc(pool_head_hpack_tbl); if (dht) hpack_dht_init(dht, pool_head_hpack_tbl->size); return dht; @@ -252,7 +263,7 @@ static inline struct hpack_dht *hpack_dht_alloc() /* free a dynamic headers table */ static inline void hpack_dht_free(struct hpack_dht *dht) { - pool_free(pool_head_hpack_tbl, dht); + hpack_free(pool_head_hpack_tbl, dht); } #endif /* _COMMON_HPACK_TBL_H */