Use calloc instead of memset(.., 0, ..) + malloc

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
ngie 2016-05-14 20:25:14 +00:00
parent e472b4a7aa
commit 0431b4d7b1

View File

@ -256,14 +256,12 @@ add_filename(struct snmp_toolinfo *snmptoolctx, const char *filename,
return (-1);
}
if ((entry = malloc(sizeof(struct fname))) == NULL) {
if ((entry = calloc(1, sizeof(struct fname))) == NULL) {
warnx("malloc() failed - %s", strerror(errno));
free(fstring);
return (-1);
}
memset(entry, 0, sizeof(struct fname));
if (cut != NULL)
asn_append_oid(&(entry->cut), cut);
strlcpy(fstring, filename, strlen(filename) + 1);
@ -1366,12 +1364,11 @@ snmp_object_add(struct snmp_toolinfo *snmptoolctx, snmp_verify_inoid_f func,
return (-1);
}
if ((obj = malloc(sizeof(struct snmp_object))) == NULL) {
if ((obj = calloc(1, sizeof(struct snmp_object))) == NULL) {
syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
return (-1);
}
memset(obj, 0, sizeof(struct snmp_object));
if (func(snmptoolctx, obj, string) < 0) {
warnx("Invalid OID - %s", string);
free(obj);