commit 597db23
wf
·
2026-05-09 08:36:13 +0000 UTC
parent b619222
Avoid memory leaks on exit In some places, swc_finalize() and cleanup were not called or called in the wrong places.
3 files changed,
+8,
-1
+3,
-0
1@@ -15,6 +15,7 @@
2 #include "types.h"
3 #include "ipc.h"
4
5+static void cleanup(void);
6 static void new_screen(struct swc_screen *);
7 static void new_window(struct swc_window *);
8 static void on_win_destroy(void *);
9@@ -217,7 +218,9 @@ setup_ipc(void) {
10 static void
11 sig_handler(int s) {
12 UNUSED(s);
13+
14 _wrn("caught deadly signal, exiting!");
15+ cleanup();
16 if (wm.dpy) {
17 swc_finalize();
18 wl_display_terminate(wm.dpy);
+1,
-0
1@@ -541,6 +541,7 @@ ipc_quit(char **arg) {
2 UNUSED(arg);
3
4 wm.running = false;
5+ swc_finalize();
6 wl_display_terminate(wm.dpy);
7
8 return (status){ true, "" }; /* NOTREACHED */
+4,
-1
1@@ -2,6 +2,7 @@
2 #include <stdlib.h>
3 #include <stdarg.h>
4
5+#include <swc.h>
6 #include <wayland-server.h>
7
8 #include "howl.h"
9@@ -53,7 +54,9 @@ _err(int ret, const char *msg, ...) {
10 fflush(stderr);
11
12 wm.running = false;
13- if (wm.dpy)
14+ if (wm.dpy) {
15+ swc_finalize();
16 wl_display_terminate(wm.dpy);
17+ }
18 exit(ret);
19 }