From b685c70fc1fbfb667c0ffa264c24c707e600bcea Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 15 Aug 2023 09:31:05 +0200 Subject: [PATCH] Revert "buffer: remove unused _drain method" This reverts commit b3f42f994ca6fc9e1a1c67a0837d66a571de7964. --- include/sqsh_primitive_private.h | 13 +++++++++++++ lib/primitive/buffer.c | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/include/sqsh_primitive_private.h b/include/sqsh_primitive_private.h index ebd0fc763..a46955aa9 100644 --- a/include/sqsh_primitive_private.h +++ b/include/sqsh_primitive_private.h @@ -137,6 +137,19 @@ SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__buffer_append( SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__buffer_move(struct SqshBuffer *buffer, struct SqshBuffer *source); +/** + * @internal + * @memberof SqshBuffer + * @brief resets the buffer size to 0. + * + * This does not free the memory allocated by the buffer so that + * the buffer can be reused. + * + * @param[in,out] buffer The SqshBuffer to drain. + */ + +void sqsh__buffer_drain(struct SqshBuffer *buffer); + /** * @internal * @memberof SqshBuffer diff --git a/lib/primitive/buffer.c b/lib/primitive/buffer.c index 3ddeb5407..c7cc11c03 100644 --- a/lib/primitive/buffer.c +++ b/lib/primitive/buffer.c @@ -114,6 +114,11 @@ sqsh__buffer_move(struct SqshBuffer *buffer, struct SqshBuffer *source) { return 0; } +void +sqsh__buffer_drain(struct SqshBuffer *buffer) { + buffer->size = 0; +} + const uint8_t * sqsh__buffer_data(const struct SqshBuffer *buffer) { return buffer->data;