[dwm] malloc'ed client in manage()

From: Filippo Erik Negroni <f.e.negroni_AT_googlemail.com>
Date: Sat, 6 Sep 2008 22:05:51 +0100

In manage(), we use calloc in order to initialise to all-zeros the newly
allocated Client structure object.

A preferable, safer and more portable way of achieving such initialisation
is to use the compiler's static initialisation.

Here is the change in manage():

- Client *c, *t = NULL;
+ static Client czeroinit;
+ Client *c, *t = NULL;

- if(!(c = calloc(1, sizeof(Client))))
- die("fatal: could not calloc() %u bytes\n", sizeof(Client));
+ if(!(c = malloc(sizeof *c)))
+ die("fatal: out of memory\n");
+ *c = czeroinit;

-- 
Cheers,
Filippo
Received on Sat Sep 06 2008 - 21:05:51 UTC

This archive was generated by hypermail 2.2.0 : Sat Sep 06 2008 - 21:12:03 UTC