diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2012-09-28 14:03:01 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2012-09-28 14:03:01 +0000 |
commit | 2cb1b8973efa4c21f90fa520714f8c1f4f04a691 (patch) | |
tree | 34e0ad6caed2999c8cd1238dbda9da6315b686b9 /usr.sbin/smtpd/lka.c | |
parent | 6e1cc28987ba7436298c5cd1d43556a1c65c3d04 (diff) |
use xmemdup() and xcalloc() helpers
ok eric@
Diffstat (limited to 'usr.sbin/smtpd/lka.c')
-rw-r--r-- | usr.sbin/smtpd/lka.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 19ac5df8b79..e7aad3db9a0 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.140 2012/09/21 10:22:29 eric Exp $ */ +/* $OpenBSD: lka.c,v 1.141 2012/09/28 14:03:00 chl Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -141,29 +141,21 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) if (iev->proc == PROC_PARENT) { switch (imsg->hdr.type) { case IMSG_CONF_START: - env->sc_rules_reload = calloc(1, sizeof *env->sc_rules); - if (env->sc_rules_reload == NULL) - fatal(NULL); - env->sc_maps_reload = calloc(1, sizeof *env->sc_maps); - if (env->sc_maps_reload == NULL) - fatal(NULL); + env->sc_rules_reload = xcalloc(1, sizeof *env->sc_rules, + "lka:sc_rules_reload"); + env->sc_maps_reload = xcalloc(1, sizeof *env->sc_maps, + "lka:sc_maps_reload"); TAILQ_INIT(env->sc_rules_reload); TAILQ_INIT(env->sc_maps_reload); return; case IMSG_CONF_RULE: - rule = calloc(1, sizeof *rule); - if (rule == NULL) - fatal(NULL); - *rule = *(struct rule *)imsg->data; + rule = xmemdup(imsg->data, sizeof *rule, "lka:rule"); TAILQ_INSERT_TAIL(env->sc_rules_reload, rule, r_entry); return; case IMSG_CONF_MAP: - map = calloc(1, sizeof *map); - if (map == NULL) - fatal(NULL); - *map = *(struct map *)imsg->data; + map = xmemdup(imsg->data, sizeof *map, "lka:map"); TAILQ_INIT(&map->m_contents); TAILQ_INSERT_TAIL(env->sc_maps_reload, map, m_entry); return; @@ -180,10 +172,7 @@ lka_imsg(struct imsgev *iev, struct imsg *imsg) case IMSG_CONF_MAP_CONTENT: map = TAILQ_LAST(env->sc_maps_reload, maplist); - mapel = calloc(1, sizeof *mapel); - if (mapel == NULL) - fatal(NULL); - *mapel = *(struct mapel *)imsg->data; + mapel = xmemdup(imsg->data, sizeof *mapel, "lka:mapel"); TAILQ_INSERT_TAIL(&map->m_contents, mapel, me_entry); return; |