Replace mh_xmalloc() with mh_xcalloc()
[mmh] / sbr / fmt_new.c
index 9a7988e..c3b1ea2 100644 (file)
@@ -43,7 +43,7 @@ new_fs(char *form, char *def_form)
                        if (fstat(fileno(fp), &st) == -1) {
                                adios(EX_IOERR, form, "unable to stat format file");
                        }
                        if (fstat(fileno(fp), &st) == -1) {
                                adios(EX_IOERR, form, "unable to stat format file");
                        }
-                       formats = mh_xmalloc((size_t) st.st_size + 1);
+                       formats = mh_xcalloc((size_t) 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");
                        }
                        if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
                                adios(EX_IOERR, form, "error reading format file");
                        }
@@ -60,7 +60,7 @@ new_fs(char *form, char *def_form)
                        if (fstat(fileno(fp), &st) == -1) {
                                adios(EX_IOERR, def_form, "unable to stat format file");
                        }
                        if (fstat(fileno(fp), &st) == -1) {
                                adios(EX_IOERR, def_form, "unable to stat format file");
                        }
-                       formats = mh_xmalloc((size_t) st.st_size + 1);
+                       formats = mh_xcalloc((size_t) 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");
                        }
                        if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
                                adios(EX_IOERR, def_form, "error reading format file");
                        }