malloc to calloc

This commit is contained in:
Jasmine Iwanek
2025-01-07 00:42:06 -05:00
parent f599e72114
commit 4e6f29a7d5
183 changed files with 245 additions and 493 deletions

View File

@@ -40,21 +40,19 @@ opendir(const char *name)
DIR *p;
/* Create a new control structure. */
p = (DIR *) malloc(sizeof(DIR));
p = (DIR *) calloc(1, sizeof(DIR));
if (p == NULL)
return (NULL);
memset(p, 0x00, sizeof(DIR));
p->flags = (DIR_F_LOWER | DIR_F_SANE);
p->offset = 0;
p->sts = 0;
/* Create a work area. */
p->dta = (char *) malloc(sizeof(FINDATA));
p->dta = (char *) calloc(1, sizeof(FINDATA));
if (p->dta == NULL) {
free(p);
return (NULL);
}
memset(p->dta, 0x00, sizeof(struct _finddata_t));
/* Add search filespec. */
strcpy(p->dir, name);