From 20ed57016563c10157093ed3785f17b5ce27fdca Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Sun, 2 Apr 2023 20:41:20 +0200 Subject: Major rework of decoder implementation --- main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index c650ea2..bc8c736 100644 --- a/main.c +++ b/main.c @@ -25,7 +25,7 @@ #include #include "decode.h" -#include "util.h" +#include "toolbox/utils.h" #include "window.h" static volatile sig_atomic_t g_signal; @@ -46,6 +46,12 @@ static void WindowDtor(struct Window** window) { *window = NULL; } +static void DecodeContextDtor(struct DecodeContext** decode_context) { + if (!*decode_context) return; + DecodeContextDestroy(*decode_context); + *decode_context = NULL; +} + int main(int argc, char* argv[]) { (void)argc; (void)argv; @@ -61,7 +67,9 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } - struct AUTO(DecodeContext)* decode_context = DecodeContextCreate(window); + struct DecodeContext + __attribute__((cleanup(DecodeContextDtor)))* decode_context = + DecodeContextCreate(window); if (!decode_context) { LOG("Failed to create decode context"); return EXIT_FAILURE; -- cgit v1.2.3