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