die if malloc sizeof(Monitor) fails
authorAnselm R Garbe <garbeam@gmail.com>
Wed, 08 Jul 2009 16:05:36 +0100
changeset 1449 8fcc541b5238
parent 1448 d012c6babc13
child 1450 b2d18a052137
die if malloc sizeof(Monitor) fails
dwm.c
--- a/dwm.c	Mon Jul 06 20:12:47 2009 +0100
+++ b/dwm.c	Wed Jul 08 16:05:36 2009 +0100
@@ -1693,7 +1693,8 @@
 #endif /* XINERAMA */
 	/* allocate monitor(s) for the new geometry setup */
 	for(i = 0; i < n; i++) {
-		m = (Monitor *)malloc(sizeof(Monitor));
+		if(!(m = (Monitor *)malloc(sizeof(Monitor))))
+			die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
 		m->next = newmons;
 		newmons = m;
 	}