simplify whatnow.c/main() function
[mmh] / uip / anno.c
index 1c97179..9e287be 100644 (file)
@@ -181,7 +181,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else if (*cp == '/' || *cp == '.') {
                        if (file)
                                adios(EX_USAGE, NULL, "only one file at a time!");
@@ -305,7 +305,7 @@ annolist(char *file, unsigned char *comp, int number)
        }
 
        /* We'll grow this buffer as needed. */
-       field = (char *)mh_xmalloc(field_size = 256);
+       field = mh_xcalloc(field_size = 256, sizeof(char));
 
        make_comp(&comp);
        length = strlen(comp); /* Convenience copy. */
@@ -325,8 +325,7 @@ annolist(char *file, unsigned char *comp, int number)
                                break;
                        }
                        if (++n >= field_size - 1) {
-                               field = (char *)mh_xrealloc(field,
-                                               field_size += 256);
+                               field = mh_xrealloc(field, field_size += 256);
                                cp = field + n - 1;
                        }
                }
@@ -343,7 +342,7 @@ annolist(char *file, unsigned char *comp, int number)
 
        } while (*field && *field != '-');
 
-       free(field);
+       mh_free0(&field);
        fclose(fp);
 
        return;
@@ -459,7 +458,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number)
        if ((fp = fdopen(fd, "r")) == NULL) {
                adios(EX_IOERR, NULL, "unable to fdopen file.");
        }
-       field = (char *)mh_xmalloc(field_size);
+       field = mh_xcalloc(field_size, sizeof(char));
 
        /*
        **  Copy lines from the input file to the temporary file
@@ -487,8 +486,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number)
                        }
 
                        if (++n >= field_size - 1) {
-                               field = (char *) mh_xrealloc(field,
-                                               field_size *= 2);
+                               field = mh_xrealloc(field, field_size *= 2);
                                cp = field + n - 1;
                        }
                }
@@ -544,7 +542,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number)
 
        } while (*field && *field != '-');
 
-       free(field);
+       mh_free0(&field);
 
        fflush(tmp);
        fflush(fp); /* The underlying fd will be closed by lkclose() */