Refactor cts pointer and free()ing on abnormal exit of associated list
authorJoel Reicher <jjr@panacea.null.org>
Sun, 4 Nov 2007 08:52:17 +0000 (08:52 +0000)
committerJoel Reicher <jjr@panacea.null.org>
Sun, 4 Nov 2007 08:52:17 +0000 (08:52 +0000)
into mhfree.c, eliminating duplication.

uip/mhfree.c
uip/mhlist.c
uip/mhn.c
uip/mhshow.c
uip/mhstore.c
uip/mhtest.c

index abaeb2b..418e5c9 100644 (file)
@@ -15,6 +15,9 @@
 #include <h/mime.h>
 #include <h/mhparse.h>
 
 #include <h/mime.h>
 #include <h/mhparse.h>
 
+/* The list of top-level contents to display */
+CT *cts = NULL;
+
 /*
  * prototypes
  */
 /*
  * prototypes
  */
@@ -22,6 +25,7 @@ void free_content (CT);
 void free_header (CT);
 void free_ctinfo (CT);
 void free_encoding (CT, int);
 void free_header (CT);
 void free_ctinfo (CT);
 void free_encoding (CT, int);
+int freects_done (int);
 
 /*
  * static prototypes
 
 /*
  * static prototypes
@@ -281,3 +285,17 @@ free_encoding (CT ct, int toplevel)
        ct->c_ceopenfnx = NULL;
     }
 }
        ct->c_ceopenfnx = NULL;
     }
 }
+
+
+int
+freects_done (int status)
+{
+    CT *ctp;
+
+    if ((ctp = cts))
+       for (; *ctp; ctp++)
+           free_content (*ctp);
+
+    exit (status);
+    return 1;  /* dead code to satisfy the compiler */
+}
index bcc4dd2..112c098 100644 (file)
@@ -93,9 +93,6 @@ pid_t xpid  = 0;
 int debugsw = 0;
 int verbosw = 0;
 
 int debugsw = 0;
 int verbosw = 0;
 
-/* The list of top-level contents to display */
-CT *cts = NULL;
-
 #define        quitser pipeser
 
 /* mhparse.c */
 #define        quitser pipeser
 
 /* mhparse.c */
@@ -112,12 +109,13 @@ void list_all_messages (CT *, int, int, int, int);
 
 /* mhfree.c */
 void free_content (CT);
 
 /* mhfree.c */
 void free_content (CT);
+extern CT *cts;
+int freects_done (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
-static int freectp_done (int);
 
 
 int
 
 
 int
@@ -132,7 +130,7 @@ main (int argc, char **argv)
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
-    done=freectp_done;
+    done=freects_done;
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -392,17 +390,3 @@ pipeser (int i)
     done (1);
     /* NOTREACHED */
 }
     done (1);
     /* NOTREACHED */
 }
-
-
-static int
-freectp_done (int status)
-{
-    CT *ctp;
-
-    if ((ctp = cts))
-       for (; *ctp; ctp++)
-           free_content (*ctp);
-
-    exit (status);
-    return 1;  /* dead code to satisfy the compiler */
-}
index 3f2d262..41eb33a 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -157,9 +157,6 @@ extern int userrs;
 int debugsw = 0;
 int verbosw = 0;
 
 int debugsw = 0;
 int verbosw = 0;
 
-/* The list of top-level contents to display */
-CT *cts = NULL;
-
 /*
  * variables for mhbuild (mhn -build)
  */
 /*
  * variables for mhbuild (mhn -build)
  */
@@ -200,12 +197,13 @@ void cache_all_messages (CT *);
 
 /* mhfree.c */
 void free_content (CT);
 
 /* mhfree.c */
 void free_content (CT);
+extern CT *cts;
+int freects_done (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
-static int freectp_done (int);
 
 
 int
 
 
 int
@@ -221,7 +219,7 @@ main (int argc, char **argv)
     CT ct, *ctp;
     FILE *fp;
 
     CT ct, *ctp;
     FILE *fp;
 
-    done=freectp_done;
+    done=freects_done;
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -705,17 +703,3 @@ pipeser (int i)
     done (1);
     /* NOTREACHED */
 }
     done (1);
     /* NOTREACHED */
 }
-
-
-static int
-freectp_done (int status)
-{
-    CT *ctp;
-
-    if ((ctp = cts))
-       for (; *ctp; ctp++)
-           free_content (*ctp);
-
-    exit (status);
-    return 1;  /* dead code to satisfy the compiler */
-}
index 4755171..b7a097c 100644 (file)
@@ -109,9 +109,6 @@ extern int userrs;
 int debugsw = 0;
 int verbosw = 0;
 
 int debugsw = 0;
 int verbosw = 0;
 
-/* The list of top-level contents to display */
-CT *cts = NULL;
-
 #define        quitser pipeser
 
 /* mhparse.c */
 #define        quitser pipeser
 
 /* mhparse.c */
@@ -128,12 +125,13 @@ void show_all_messages (CT *);
 
 /* mhfree.c */
 void free_content (CT);
 
 /* mhfree.c */
 void free_content (CT);
+extern CT *cts;
+int freects_done (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
-static int freectp_done (int);
 
 
 int
 
 
 int
@@ -148,7 +146,7 @@ main (int argc, char **argv)
     CT ct, *ctp;
     FILE *fp;
 
     CT ct, *ctp;
     FILE *fp;
 
-    done=freectp_done;
+    done=freects_done;
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -472,17 +470,3 @@ pipeser (int i)
     done (1);
     /* NOTREACHED */
 }
     done (1);
     /* NOTREACHED */
 }
-
-
-static int
-freectp_done (int status)
-{
-    CT *ctp;
-
-    if ((ctp = cts))
-       for (; *ctp; ctp++)
-           free_content (*ctp);
-
-    exit (status);
-    return 1;  /* dead code to satisfy the compiler */
-}
index b1f57fe..4d1ebe0 100644 (file)
@@ -87,9 +87,6 @@ extern int userrs;
 int debugsw = 0;
 int verbosw = 0;
 
 int debugsw = 0;
 int verbosw = 0;
 
-/* The list of top-level contents to display */
-CT *cts = NULL;
-
 #define        quitser pipeser
 
 /* mhparse.c */
 #define        quitser pipeser
 
 /* mhparse.c */
@@ -106,12 +103,13 @@ void store_all_messages (CT *);
 
 /* mhfree.c */
 void free_content (CT);
 
 /* mhfree.c */
 void free_content (CT);
+extern CT *cts;
+int freects_done (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
 
 /*
  * static prototypes
  */
 static RETSIGTYPE pipeser (int);
-static int freectp_done (int);
 
 
 int
 
 
 int
@@ -126,7 +124,7 @@ main (int argc, char **argv)
     CT ct, *ctp;
     FILE *fp;
 
     CT ct, *ctp;
     FILE *fp;
 
-    done=freectp_done;
+    done=freects_done;
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -404,17 +402,3 @@ pipeser (int i)
     done (1);
     /* NOTREACHED */
 }
     done (1);
     /* NOTREACHED */
 }
-
-
-static int
-freectp_done (int status)
-{
-    CT *ctp;
-
-    if ((ctp = cts))
-       for (; *ctp; ctp++)
-           free_content (*ctp);
-
-    exit (status);
-    return 1;  /* dead code to satisfy the compiler */
-}
index 985147c..6771bdb 100644 (file)
@@ -89,9 +89,6 @@ pid_t xpid  = 0;
 int debugsw = 0;
 int verbosw = 0;
 
 int debugsw = 0;
 int verbosw = 0;
 
-/* The list of top-level contents to display */
-CT *cts = NULL;
-
 #define        quitser pipeser
 
 /* mhparse.c */
 #define        quitser pipeser
 
 /* mhparse.c */
@@ -108,13 +105,14 @@ void flush_errors (void);
 
 /* mhfree.c */
 void free_content (CT);
 
 /* mhfree.c */
 void free_content (CT);
+extern CT *cts;
+int freects_done (int);
 
 /*
  * static prototypes
  */
 static int write_content (CT *, char *);
 static RETSIGTYPE pipeser (int);
 
 /*
  * static prototypes
  */
 static int write_content (CT *, char *);
 static RETSIGTYPE pipeser (int);
-static int freectp_done (int);
 
 
 int
 
 
 int
@@ -128,7 +126,7 @@ main (int argc, char **argv)
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
     struct msgs *mp = NULL;
     CT ct, *ctp;
 
-    done=freectp_done;
+    done=freects_done;
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -398,17 +396,3 @@ pipeser (int i)
     done (1);
     /* NOTREACHED */
 }
     done (1);
     /* NOTREACHED */
 }
-
-
-static int
-freectp_done (int status)
-{
-    CT *ctp;
-
-    if ((ctp = cts))
-       for (; *ctp; ctp++)
-           free_content (*ctp);
-
-    exit (status);
-    return 1;  /* dead code to satisfy the compiler */
-}