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.
This commit is contained in:
Willy Tarreau 2019-08-08 08:06:27 +02:00
parent 3b091f80aa
commit e0d0b4089d
3 changed files with 6 additions and 15 deletions

View File

@ -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 <buf> which must be allocated
| ret: void | and marks it empty
--------------------+------------------+---------------------------------------
b_drop | buffer *buf | releases <buf> only if it is allocated
__b_free | buffer *buf | releases <buf> which must be allocated
| ret: void | and marks it empty
--------------------+------------------+---------------------------------------
b_free | buffer *buf | releases <buf> only if it is allocated

View File

@ -112,7 +112,7 @@ static inline struct buffer *b_alloc_fast(struct buffer *buf)
/* Releases buffer <buf> (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 <buf> if allocated, and marks it empty. */
static inline void b_drop(struct buffer *buf)
{
if (buf->size)
__b_drop(buf);
}
/* Releases buffer <buf> 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 <buf> is allocated. If an allocation is needed, it ensures that

View File

@ -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);
}