Fix uip/whom.c for C89 compatibility
[mmh] / uip / anno.c
index 1c97179..33d2b49 100644 (file)
@@ -53,6 +53,8 @@ static struct swit switches[] = {
        { NULL, 0 }
 };
 
+char *version=VERSION;
+
 /*
 ** static prototypes
 */
@@ -181,7 +183,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 +307,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 +327,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 +344,7 @@ annolist(char *file, unsigned char *comp, int number)
 
        } while (*field && *field != '-');
 
-       free(field);
+       mh_free0(&field);
        fclose(fp);
 
        return;
@@ -459,7 +460,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 +488,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 +544,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() */