X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Ffmt_new.c;h=c1386d4c710bb4de354bbbbc9d219b6753ccc5eb;hp=9a7988ebb07993aa2c3a1a027dcfca4adf49a12f;hb=18591f8e001ecedbee48a51c1d1f08ebaa1c15c8;hpb=5ba9c2f13fedf1d8d6ed907ef1f505616290efaa diff --git a/sbr/fmt_new.c b/sbr/fmt_new.c index 9a7988e..c1386d4 100644 --- a/sbr/fmt_new.c +++ b/sbr/fmt_new.c @@ -30,12 +30,12 @@ new_fs(char *form, char *def_form) 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"); @@ -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"); } - formats = mh_xmalloc((size_t) st.st_size + 1); + 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"); } @@ -52,7 +52,7 @@ new_fs(char *form, char *def_form) } } 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"); @@ -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"); } - formats = mh_xmalloc((size_t) st.st_size + 1); + 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"); }