diff --git a/include/haproxy/chunk.h b/include/haproxy/chunk.h index b5d515170..43c7270ad 100644 --- a/include/haproxy/chunk.h +++ b/include/haproxy/chunk.h @@ -46,18 +46,8 @@ int chunk_asciiencode(struct buffer *dst, struct buffer *src, char qc); int chunk_strcmp(const struct buffer *chk, const char *str); int chunk_strcasecmp(const struct buffer *chk, const char *str); struct buffer *get_trash_chunk(void); -struct buffer *alloc_trash_chunk(void); int init_trash_buffers(int first); -/* - * free a trash chunk allocated by alloc_trash_chunk(). NOP on NULL. - */ -static inline void free_trash_chunk(struct buffer *chunk) -{ - pool_free(pool_head_trash, chunk); -} - - static inline void chunk_reset(struct buffer *chk) { chk->data = 0; @@ -96,6 +86,34 @@ static inline void chunk_initstr(struct buffer *chk, const char *str) chk->size = 0; /* mark it read-only */ } +/* + * Allocate a trash chunk from the reentrant pool. The buffer starts at the + * end of the chunk. This chunk must be freed using free_trash_chunk(). This + * call may fail and the caller is responsible for checking that the returned + * pointer is not NULL. + */ +static forceinline struct buffer *alloc_trash_chunk(void) +{ + struct buffer *chunk; + + chunk = pool_alloc(pool_head_trash); + if (chunk) { + char *buf = (char *)chunk + sizeof(struct buffer); + *buf = 0; + chunk_init(chunk, buf, + pool_head_trash->size - sizeof(struct buffer)); + } + return chunk; +} + +/* + * free a trash chunk allocated by alloc_trash_chunk(). NOP on NULL. + */ +static forceinline void free_trash_chunk(struct buffer *chunk) +{ + pool_free(pool_head_trash, chunk); +} + /* copies chunk into . Returns 0 in case of failure. */ static inline int chunk_cpy(struct buffer *chk, const struct buffer *src) { diff --git a/src/chunk.c b/src/chunk.c index d67e9f1d2..2d24fa596 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -98,26 +98,6 @@ int init_trash_buffers(int first) return 1; } -/* - * Allocate a trash chunk from the reentrant pool. The buffer starts at the - * end of the chunk. This chunk must be freed using free_trash_chunk(). This - * call may fail and the caller is responsible for checking that the returned - * pointer is not NULL. - */ -struct buffer *alloc_trash_chunk(void) -{ - struct buffer *chunk; - - chunk = pool_alloc(pool_head_trash); - if (chunk) { - char *buf = (char *)chunk + sizeof(struct buffer); - *buf = 0; - chunk_init(chunk, buf, - pool_head_trash->size - sizeof(struct buffer)); - } - return chunk; -} - /* * Does an snprintf() at the beginning of chunk , respecting the limit of * at most chk->size chars. If the chk->len is over, nothing is added. Returns