diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-02 20:41:20 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-07 13:48:02 +0200 |
commit | 20ed57016563c10157093ed3785f17b5ce27fdca (patch) | |
tree | 73346b7a4b0ce66bf1d4b651f714fb1a315d247f /main.c | |
parent | e59239d9eb7a48844104b2fbbcb96c069204950a (diff) |
Major rework of decoder implementation
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -25,7 +25,7 @@ #include <unistd.h> #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; |