mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 09:10:28 +00:00
Replace malloc + memset(.., 0, ..) with calloc calls
MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
2501437203
commit
4e312050f0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299803
|
@ -268,13 +268,11 @@ enum_pair_insert(struct enum_pairs *headp, int32_t enum_val, char *enum_str)
|
|||
{
|
||||
struct enum_pair *e_new;
|
||||
|
||||
if ((e_new = malloc(sizeof(struct enum_pair))) == NULL) {
|
||||
if ((e_new = calloc(1, sizeof(struct enum_pair))) == NULL) {
|
||||
syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
memset(e_new, 0, sizeof(struct enum_pair));
|
||||
|
||||
if ((e_new->enum_str = malloc(strlen(enum_str) + 1)) == NULL) {
|
||||
syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
|
||||
free(e_new);
|
||||
|
@ -557,12 +555,11 @@ snmp_enumtc_init(char *name)
|
|||
{
|
||||
struct enum_type *enum_tc;
|
||||
|
||||
if ((enum_tc = malloc(sizeof(struct enum_type))) == NULL) {
|
||||
if ((enum_tc = calloc(1, sizeof(struct enum_type))) == NULL) {
|
||||
syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
memset(enum_tc, 0, sizeof(struct enum_type));
|
||||
if ((enum_tc->name = malloc(strlen(name) + 1)) == NULL) {
|
||||
syslog(LOG_ERR, "malloc() failed: %s", strerror(errno));
|
||||
free(enum_tc);
|
||||
|
|
Loading…
Reference in a new issue