diff --git a/include/common/buffer.h b/include/common/buffer.h index 52565dd9b..2c992c7f8 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -409,6 +409,13 @@ static inline struct buffer *b_alloc(struct buffer **buf) return *buf; } +/* Releases buffer *buf. + */ +static inline void b_free(struct buffer **buf) +{ + pool_free2(pool2_buffer, *buf); +} + #endif /* _COMMON_BUFFER_H */ /* diff --git a/src/peers.c b/src/peers.c index af413c69a..5371e492d 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1302,7 +1302,7 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio out_fail_rep_buf: pool_free2(pool2_channel, s->rep); out_fail_rep: - pool_free2(pool2_buffer, s->req->buf); + b_free(&s->req->buf); out_fail_req_buf: pool_free2(pool2_channel, s->req); out_fail_req: diff --git a/src/session.c b/src/session.c index 6770ee484..ebe992ba1 100644 --- a/src/session.c +++ b/src/session.c @@ -565,11 +565,11 @@ int session_complete(struct session *s) /* Error unrolling */ out_free_rep_buf: - pool_free2(pool2_buffer, s->rep->buf); + b_free(&s->rep->buf); out_free_rep: pool_free2(pool2_channel, s->rep); out_free_req_buf: - pool_free2(pool2_buffer, s->req->buf); + b_free(&s->req->buf); out_free_req: pool_free2(pool2_channel, s->req); out_free_task: @@ -618,8 +618,8 @@ static void session_free(struct session *s) if (s->rep->pipe) put_pipe(s->rep->pipe); - pool_free2(pool2_buffer, s->req->buf); - pool_free2(pool2_buffer, s->rep->buf); + b_free(&s->req->buf); + b_free(&s->rep->buf); pool_free2(pool2_channel, s->req); pool_free2(pool2_channel, s->rep);