From 5337d6c8e9387311b94c9e2f51296bc7bf6cfad8 Mon Sep 17 00:00:00 2001 From: ngie Date: Sun, 15 May 2016 00:40:05 +0000 Subject: Replace malloc + memset(.., 0, ..) with calloc calls MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'usr.sbin/bsnmpd') diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c index 07fc83b..7e2b721 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c @@ -55,12 +55,11 @@ snmp_mapping_init(void) { struct snmp_mappings *m; - if ((m = malloc(sizeof(struct snmp_mappings))) == NULL) { + if ((m = calloc(1, sizeof(struct snmp_mappings))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (NULL); } - memset(m, 0, sizeof(struct snmp_mappings)); return (m); } @@ -478,13 +477,11 @@ snmp_syntax_insert(struct snmp_idxlist *headp, struct enum_pairs *enums, { struct index *idx; - if ((idx = malloc(sizeof(struct index))) == NULL) { + if ((idx = calloc(1, sizeof(struct index))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (-1); } - memset(idx, 0, sizeof(struct index)); - if (snmp_index_insert(headp, idx) < 0) { free(idx); return (-1); -- cgit v1.1