[hackers] [dwm] die if malloc sizeof(Monitor) fails || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Wed, 8 Jul 2009 15:05:41 +0000 (UTC)

changeset: 1449:8fcc541b5238
tag: tip
user: Anselm R Garbe <garbeam_AT_gmail.com>
date: Wed Jul 08 16:05:36 2009 +0100
files: dwm.c
description:
die if malloc sizeof(Monitor) fails

diff -r d012c6babc13 -r 8fcc541b5238 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;
         }
Received on Wed Jul 08 2009 - 15:05:41 UTC

This archive was generated by hypermail 2.2.0 : Wed Jul 08 2009 - 15:12:05 UTC