diff --git a/include/haproxy/pool.h b/include/haproxy/pool.h index 108e00e5f..a089f035a 100644 --- a/include/haproxy/pool.h +++ b/include/haproxy/pool.h @@ -143,7 +143,7 @@ unsigned long long pool_total_allocated(void); unsigned long long pool_total_used(void); void pool_flush(struct pool_head *pool); void pool_gc(struct pool_head *pool_ctx); -struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags); +struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int flags, const char *file, unsigned int line); struct pool_head *create_pool_from_reg(const char *name, struct pool_registration *reg); void create_pool_callback(struct pool_head **ptr, char *name, struct pool_registration *reg); void *pool_destroy(struct pool_head *pool); @@ -152,6 +152,9 @@ void *__pool_alloc(struct pool_head *pool, unsigned int flags); void __pool_free(struct pool_head *pool, void *ptr); void pool_inspect_item(const char *msg, struct pool_head *pool, const void *item, const void *caller, ssize_t ofs); +#define create_pool(name, size, flags) \ + create_pool_with_loc(name, size, flags, __FILE__, __LINE__) + /****************** Thread-local cache management ******************/ diff --git a/src/pool.c b/src/pool.c index c3eb98189..3275bcb9b 100644 --- a/src/pool.c +++ b/src/pool.c @@ -291,8 +291,11 @@ static int mem_should_fail(const struct pool_head *pool) * - MEM_F_SHARED to indicate that the pool may be shared with other users * - MEM_F_EXACT to indicate that the size must not be rounded up * The name must be a stable pointer during all the program's life time. + * The file and line are passed to store the registration location in the + * registration struct. Use create_pool() instead which does it for free. */ -struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags) +struct pool_head *create_pool_with_loc(const char *name, unsigned int size, unsigned int flags, + const char *file, unsigned int line) { struct pool_registration *reg; struct pool_head *pool; @@ -302,6 +305,8 @@ struct pool_head *create_pool(const char *name, unsigned int size, unsigned int return NULL; reg->name = name; + reg->file = file; + reg->line = line; reg->size = size; reg->flags = flags; reg->align = 0;