Use calloc(3) instead of malloc(3) + memset(3)

While here check the return of calloc(3)
This commit is contained in:
Baptiste Daroussin 2015-05-10 11:18:01 +00:00
parent 36dc2e6885
commit a1d3bf2e8f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=282720

View File

@ -234,8 +234,10 @@ read_userconfig(char const * file)
buf = NULL;
linecap = 0;
extendarray(&config.groups, &config.numgroups, 200);
memset(config.groups, 0, config.numgroups * sizeof(char *));
config.numgroups = 200;
config.groups = calloc(config.numgroups, sizeof(char *));
if (config.groups == NULL)
err(1, "calloc()");
if (file == NULL)
file = _PATH_PW_CONF;