diff --git a/include/haproxy/pool-t.h b/include/haproxy/pool-t.h index 524c871b8..4a8752ad6 100644 --- a/include/haproxy/pool-t.h +++ b/include/haproxy/pool-t.h @@ -70,7 +70,7 @@ struct pool_cache_head { */ struct pool_registration { struct list list; /* link element */ - char name[12]; /* name of the pool */ + const char *name; /* name of the pool */ unsigned int size; /* expected object size */ unsigned int flags; /* MEM_F_* */ unsigned int align; /* expected alignment; 0=unspecified */ diff --git a/include/haproxy/pool.h b/include/haproxy/pool.h index 963e5b6ae..3c9651e40 100644 --- a/include/haproxy/pool.h +++ b/include/haproxy/pool.h @@ -123,8 +123,8 @@ 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(char *name, unsigned int size, unsigned int flags); -struct pool_head *create_pool_from_reg(char *name, struct pool_registration *reg); +struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags); +struct pool_head *create_pool_from_reg(const char *name, struct pool_registration *reg); void create_pool_callback(struct pool_head **ptr, char *name, unsigned int size); void *pool_destroy(struct pool_head *pool); void pool_destroy_all(void); diff --git a/src/pool.c b/src/pool.c index 43359403f..507a52032 100644 --- a/src/pool.c +++ b/src/pool.c @@ -290,8 +290,9 @@ static int mem_should_fail(const struct pool_head *pool) * is available for a new creation. Two flags are supported : * - 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. */ -struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags) +struct pool_head *create_pool(const char *name, unsigned int size, unsigned int flags) { struct pool_registration *reg; struct pool_head *pool; @@ -300,7 +301,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags) if (!reg) return NULL; - strlcpy2(reg->name, name, sizeof(reg->name)); + reg->name = name; reg->size = size; reg->flags = flags; reg->align = 0; @@ -314,7 +315,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags) /* create a pool from a pool registration. All configuration is taken from * there. */ -struct pool_head *create_pool_from_reg(char *name, struct pool_registration *reg) +struct pool_head *create_pool_from_reg(const char *name, struct pool_registration *reg) { unsigned int extra_mark, extra_caller, extra; unsigned int flags = reg->flags;