commit 3ce2e81
uint
·
2026-06-02 16:12:18 +0000 UTC
parent 821508e
X11: return NULL on init failure
2 files changed,
+9,
-3
+8,
-2
1@@ -11,10 +11,16 @@ MausWindow* maus_init(const char* title, int x, int y, int width, int height)
2 maus_log(stderr, "backend auto-selected: X11");
3
4 Display* d = XOpenDisplay(NULL);
5- if (!d)
6- maus_die("could not open X11 display");
7+ if (!d) {
8+ maus_die("failed to open X11 display");
9+ return NULL;
10+ }
11
12 uint32_t* px = malloc(sizeof(uint32_t)*width*height);
13+ if (!px) {
14+ maus_log(stderr, "failed to allocate %dx%d pixel grid", width, height);
15+ return NULL;
16+ }
17
18 MausWindow* win = malloc(sizeof(MausWindow));
19 win->display = d;
+1,
-1
1@@ -38,7 +38,7 @@
2 /* log message to output `fd` and die */
3 void maus_die(const char* fmt, ...);
4
5-/* initialise and create the window */
6+/* initialise and create the window. returns NULL on fail */
7 MausWindow* maus_init(const char* title, int x, int y, int width, int height);
8
9 /* log message to output `fd` */