From: Willy Tarreau Date: Thu, 8 Aug 2019 06:06:27 +0000 (+0200) Subject: CLEANUP: buffer: replace b_drop() with b_free() X-Git-Tag: v2.1-dev2~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0d0b4089dd1c1dad94580de9de80985730da593;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/doc/internals/buffer-api.txt b/doc/internals/buffer-api.txt index abb5e9f769..6d192c19d4 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 34a3e95d2d..0d44ec8d5d 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 a135dcb248..913de63897 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); }