From ed004cba0e8d1d383def76f795b1e63ba0aaa89a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 9 Feb 2025 15:04:27 +0100 Subject: First commit (everything was written 2024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- liblog_destroy_context.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 liblog_destroy_context.c (limited to 'liblog_destroy_context.c') diff --git a/liblog_destroy_context.c b/liblog_destroy_context.c new file mode 100644 index 0000000..57192ac --- /dev/null +++ b/liblog_destroy_context.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + +int +liblog_destroy_context(struct liblog_context *ctx) +{ + int ret = 0; + + if (!ctx) + return 0; + + while (ctx->noutputs) + ret |= liblog_destroy_output(&ctx->outputs[--ctx->noutputs]); + free(ctx->outputs); + ctx->outputs = NULL; + + if (ctx->internal_state) { + free(ctx->internal_state->msg.prefix); + free(ctx->internal_state->msg.text); + free(ctx->internal_state); + ctx->internal_state = NULL; + } + + return ret; +} + +#else + +int main(void) {return 0;} /* TODO test */ + +#endif -- cgit v1.2.3-70-g09d2