Replace malloc + memset(.., 0, ..) with calloc calls

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2016-05-15 00:40:05 +00:00
parent 27c7c23864
commit 6047e12ca5

View File

@ -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);