summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2023-04-02 20:41:20 +0200
committerMikhail Burakov <mburakov@mailbox.org>2023-04-07 13:48:02 +0200
commit20ed57016563c10157093ed3785f17b5ce27fdca (patch)
tree73346b7a4b0ce66bf1d4b651f714fb1a315d247f /main.c
parente59239d9eb7a48844104b2fbbcb96c069204950a (diff)
Major rework of decoder implementation
Diffstat (limited to 'main.c')
-rw-r--r--main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/main.c b/main.c
index c650ea2..bc8c736 100644
--- a/main.c
+++ b/main.c
@@ -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;