From e0d0b4089dd1c1dad94580de9de80985730da593 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 8 Aug 2019 08:06:27 +0200 Subject: [PATCH] CLEANUP: buffer: replace b_drop() with b_free() Since last commit there's no point anymore in having two variants of the same function, let's switch to b_free() only. __b_drop() was renamed to __b_free() for obvious consistency reasons. --- doc/internals/buffer-api.txt | 5 +---- include/common/buffer.h | 12 +++--------- src/stream.c | 4 ++-- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/doc/internals/buffer-api.txt b/doc/internals/buffer-api.txt index abb5e9f76..6d192c19d 100644 --- a/doc/internals/buffer-api.txt +++ b/doc/internals/buffer-api.txt @@ -567,10 +567,7 @@ b_alloc_fast | buffer *buf | allocates a buffer and assigns it to | | never calls malloc(), so it can fail | | even if some memory is available --------------------+------------------+--------------------------------------- -__b_drop | buffer *buf | releases which must be allocated - | ret: void | and marks it empty ---------------------+------------------+--------------------------------------- -b_drop | buffer *buf | releases only if it is allocated +__b_free | buffer *buf | releases which must be allocated | ret: void | and marks it empty --------------------+------------------+--------------------------------------- b_free | buffer *buf | releases only if it is allocated diff --git a/include/common/buffer.h b/include/common/buffer.h index 34a3e95d2..0d44ec8d5 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -112,7 +112,7 @@ static inline struct buffer *b_alloc_fast(struct buffer *buf) /* Releases buffer (no check of emptiness). The buffer's head is marked * empty. */ -static inline void __b_drop(struct buffer *buf) +static inline void __b_free(struct buffer *buf) { char *area = buf->area; @@ -124,17 +124,11 @@ static inline void __b_drop(struct buffer *buf) pool_free(pool_head_buffer, area); } -/* Releases buffer if allocated, and marks it empty. */ -static inline void b_drop(struct buffer *buf) -{ - if (buf->size) - __b_drop(buf); -} - /* Releases buffer if allocated, and marks it empty. */ static inline void b_free(struct buffer *buf) { - b_drop(buf); + if (buf->size) + __b_free(buf); } /* Ensures that is allocated. If an allocation is needed, it ensures that diff --git a/src/stream.c b/src/stream.c index a135dcb24..913de6389 100644 --- a/src/stream.c +++ b/src/stream.c @@ -404,8 +404,8 @@ static void stream_free(struct stream *s) HA_SPIN_UNLOCK(BUF_WQ_LOCK, &buffer_wq_lock); } if (s->req.buf.size || s->res.buf.size) { - b_drop(&s->req.buf); - b_drop(&s->res.buf); + b_free(&s->req.buf); + b_free(&s->res.buf); offer_buffers(NULL, tasks_run_queue); }