FILE *fp;
if (formats) {
- free(formats);
+ mh_free0(&formats);
}
if (form) {
if (*form == '=') {
- formats = getcpy(form+1);
+ formats = mh_xstrdup(form+1);
} else {
if ((fp = fopen(etcpath(form), "r")) == NULL) {
adios(EX_IOERR, form, "unable to open format file");
if (fstat(fileno(fp), &st) == -1) {
adios(EX_IOERR, form, "unable to stat format file");
}
- formats = mh_xcalloc((size_t) st.st_size + 1, sizeof(char));
+ formats = mh_xcalloc(st.st_size + 1, sizeof(char));
if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
adios(EX_IOERR, form, "error reading format file");
}
}
} else if (def_form) {
if (*def_form == '=') {
- formats = getcpy(def_form+1);
+ formats = mh_xstrdup(def_form+1);
} else {
if ((fp = fopen(etcpath(def_form), "r")) == NULL) {
adios(EX_IOERR, def_form, "unable to open format file");
if (fstat(fileno(fp), &st) == -1) {
adios(EX_IOERR, def_form, "unable to stat format file");
}
- formats = mh_xcalloc((size_t) st.st_size + 1, sizeof(char));
+ formats = mh_xcalloc(st.st_size + 1, sizeof(char));
if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
adios(EX_IOERR, def_form, "error reading format file");
}