On Wed, 09 Sep 2015 13:14:16 +0200, Alexander Bluhm wrote:
> Instead of having global variables containing the libevent structures,
> allocate them with malloc. This makes the address space layout
> more random.
That huge if() makes things a bit harder to read. Doing the NULL
check separately from the calls to malloc() might help. E.g.
ev_ctlaccept = malloc(sizeof(struct event));
ev_ctlread = malloc(sizeof(struct event));
ev_ctlwrite = malloc(sizeof(struct event));
ev_klog = malloc(sizeof(struct event));
ev_sendsys = malloc(sizeof(struct event));
ev_udp = malloc(sizeof(struct event));
ev_udp6 = malloc(sizeof(struct event));
ev_bind = malloc(sizeof(struct event));
ev_listen = malloc(sizeof(struct event));
ev_unix = reallocarray(NULL, nunix, sizeof(struct event));
ev_hup = malloc(sizeof(struct event));
ev_int = malloc(sizeof(struct event));
ev_quit = malloc(sizeof(struct event));
ev_term = malloc(sizeof(struct event));
ev_mark = malloc(sizeof(struct event));
if (ev_ctlaccept == NULL || ev_ctlread == NULL || ev_ctlwrite == NULL ||
ev_klog == NULL || ev_sendsys == NULL || ev_udp == NULL ||
ev_udp6 == NULL || ev_bind == NULL || ev_int == NULL ||
ev_quit == NULL || ev_term == NULL || ev_mark == NULL)
err(1, "malloc");
- todd