* patch #3967: Create a mh_xrealloc function to prevent mistakes when
authorJosh Bressers <josh@bress.net>
Mon, 2 Jan 2006 03:25:18 +0000 (03:25 +0000)
committerJosh Bressers <josh@bress.net>
Mon, 2 Jan 2006 03:25:18 +0000 (03:25 +0000)
calling realloc.

34 files changed:
ChangeLog
h/utils.h
sbr/brkstring.c
sbr/fmt_addr.c
sbr/folder_read.c
sbr/folder_realloc.c
sbr/mf.c
sbr/seq_list.c
sbr/utils.c
sbr/vfgets.c
uip/anno.c
uip/annosbr.c
uip/conflict.c
uip/dropsbr.c
uip/flist.c
uip/folder.c
uip/mark.c
uip/mhlist.c
uip/mhlsbr.c
uip/mhn.c
uip/mhpath.c
uip/mhshow.c
uip/mhstore.c
uip/mhtest.c
uip/msh.c
uip/packf.c
uip/pick.c
uip/popsbr.c
uip/refile.c
uip/replsbr.c
uip/rmm.c
uip/scan.c
uip/sendsbr.c
uip/sortm.c

index f8d1c8d..757d2eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2006-01-01  Josh Bressers <josh@bress.net>
 
 2006-01-01  Josh Bressers <josh@bress.net>
 
+       * patch #3967: Create a mh_xrealloc function to prevent mistakes when
+       calling realloc.
+
+2006-01-01  Josh Bressers <josh@bress.net>
+
        * patch #3966: Create a mh_xmalloc function to prevent mistakes when
        calling malloc.
 
        * patch #3966: Create a mh_xmalloc function to prevent mistakes when
        calling malloc.
 
index aba8fc4..8648b3f 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -6,4 +6,4 @@
  */
 
 void *mh_xmalloc(size_t);
  */
 
 void *mh_xmalloc(size_t);
-
+void *mh_xrealloc(void *, size_t);
index 255abf7..d2f71aa 100644 (file)
@@ -48,8 +48,7 @@ brkstring (char *str, char *brksep, char *brkterm)
        /* enlarge pointer array, if necessary */
        if (i >= len) {
            len += NUMBROKEN;
        /* enlarge pointer array, if necessary */
        if (i >= len) {
            len += NUMBROKEN;
-           if (!(broken = realloc (broken, (size_t) (len * sizeof(*broken)))))
-               adios (NULL, "unable to realloc array in brkstring");
+           broken = mh_xrealloc (broken, (size_t) (len * sizeof(*broken)));
        }
 
        while (brkany (c = *s, brksep))
        }
 
        while (brkany (c = *s, brksep))
index 97f4271..d71d956 100644 (file)
@@ -29,11 +29,9 @@ static unsigned int bufsiz;  /* current size of buf         */
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
-               buf = realloc (buf, bufsiz);\
+               buf = mh_xrealloc (buf, bufsiz);\
                dst = buf + i;\
                last_dst = buf + n;\
                dst = buf + i;\
                last_dst = buf + n;\
-               if (! buf)\
-                   adios (NULL, "formataddr: couldn't get buffer space");\
                bufend = buf + bufsiz;\
            }
 
                bufend = buf + bufsiz;\
            }
 
index 8e3a3ff..0dec537 100644 (file)
@@ -76,10 +76,7 @@ folder_read (char *name)
             */
            if (mp->nummsg >= len) {
                len += NUMMSGS;
             */
            if (mp->nummsg >= len) {
                len += NUMMSGS;
-               if (!(mi = (int *) realloc (mi,
-                       (size_t) (len * sizeof(*mi))))) {
-                   adios (NULL, "unable to allocate storage");
-               }
+               mi = (int *) mh_xrealloc (mi, (size_t) (len * sizeof(*mi)));
            }
 
            /* Check if this is the first message we've seen */
            }
 
            /* Check if this is the first message we've seen */
index 753da2e..e7c4bc4 100644 (file)
@@ -47,10 +47,7 @@ folder_realloc (struct msgs *mp, int lo, int hi)
         * status array.  So we don't have to move anything and can
         * just realloc the message status array.
         */
         * status array.  So we don't have to move anything and can
         * just realloc the message status array.
         */
-       if (!(mp->msgstats = realloc (mp->msgstats, MSGSTATSIZE(mp, lo, hi)))) {
-           advise (NULL, "unable to reallocate message storage");
-           return NULL;
-       }
+       mp->msgstats = mh_xrealloc (mp->msgstats, MSGSTATSIZE(mp, lo, hi));
     } else {
        /*
         * We are changing the offset of the message status
     } else {
        /*
         * We are changing the offset of the message status
index 9a2c647..518a184 100644 (file)
--- a/sbr/mf.c
+++ b/sbr/mf.c
@@ -975,13 +975,8 @@ mfgets (FILE *in, char **bp)
                break;
        }
        if (cp >= ep) {
                break;
        }
        if (cp >= ep) {
-           if (!(dp = realloc (pp, (size_t) (len += BUFSIZ)))) {
-               free (pp);
-               pp = NULL;
-               return NOTOK;
-           }
-           else
-               cp += dp - pp, ep = (pp = cp) + len - 2;
+           dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ));
+           cp += dp - pp, ep = (pp = cp) + len - 2;
        }
     }
 }
        }
     }
 }
index ecc03bf..f5dbb65 100644 (file)
@@ -75,8 +75,7 @@ seq_list(struct msgs *mp, char *seqname)
            char *newbuf;
 
            len += MAXBUFFER;
            char *newbuf;
 
            len += MAXBUFFER;
-           if (!(newbuf = realloc (buffer, (size_t) len)))
-               adios (NULL, "unable to realloc storage in seq_list");
+           newbuf = mh_xrealloc (buffer, (size_t) len);
            bp = newbuf + (bp - buffer);
            buffer = newbuf;
        }
            bp = newbuf + (bp - buffer);
            buffer = newbuf;
        }
index bc17177..7dfe900 100644 (file)
@@ -27,3 +27,18 @@ mh_xmalloc(size_t size)
 
     return memory;
 }
 
     return memory;
 }
+
+void *
+mh_xrealloc(void *ptr, size_t size)
+{
+    void *memory;
+
+    if (size == 0)
+        adios(NULL, "Tried to realloc 0bytes");
+
+    memory = realloc(ptr, size);
+    if (!memory)
+        adios(NULL, "Realloc failed");
+
+    return memory;
+}
index beb0afd..c6a39ea 100644 (file)
@@ -66,12 +66,9 @@ wrong_guess:
        if (cp >= ep) {
            int curlen = cp - pp;
 
        if (cp >= ep) {
            int curlen = cp - pp;
 
-           if (!(dp = realloc (pp, (size_t) (len += BUFSIZ)))) {
-               adios (NULL, "unable to allocate string storage");
-           } else {
-               cp = dp + curlen;
-               ep = (pp = dp) + len - 1;
-           }
+           dp = mh_xrealloc (pp, (size_t) (len += BUFSIZ));
+           cp = dp + curlen;
+           ep = (pp = dp) + len - 1;
        }
     }
 }
        }
     }
 }
index d90e0f6..9fbb37f 100644 (file)
@@ -233,9 +233,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 337a01b..2ad873e 100644 (file)
@@ -120,8 +120,7 @@ annolist(char *file, char *comp, char *text, int number)
            }
 
            if (++n >= field_size - 1) {
            }
 
            if (++n >= field_size - 1) {
-               if ((field = (char *)realloc((void *)field, field_size += 256)) == (char *)0)
-                   adios(NULL, "can't grow field buffer.");
+               field = (char *) mh_xrealloc((void *)field, field_size += 256);
                
                cp = field + n - 1;
            }
                
                cp = field + n - 1;
            }
@@ -262,8 +261,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, in
                }
 
                if (++n >= field_size - 1) {
                }
 
                if (++n >= field_size - 1) {
-                   if ((field = (char *)realloc((void *)field, field_size *= 2)) == (char *)0)
-                       adios(NULL, "can't grow field buffer.");
+                   field = (char *) mh_xrealloc((void *)field, field_size *= 2);
                
                    cp = field + n - 1;
                }
                
                    cp = field + n - 1;
                }
index 5097119..1713b15 100644 (file)
@@ -205,9 +205,8 @@ grp_names (void)
        if (i >= numgroups) {
            if (numgroups >= maxgroups) {
                maxgroups += NGRPS;
        if (i >= numgroups) {
            if (numgroups >= maxgroups) {
                maxgroups += NGRPS;
-               if (!(grps = (char **) realloc(grps,
-                       (size_t) (maxgroups * sizeof(*grps)))))
-                   adios (NULL, "unable to reallocate group name storage");
+               grps = (char **) mh_xrealloc(grps,
+                   (size_t) (maxgroups * sizeof(*grps)));
            }
            grps[numgroups++] = getcpy (gr->gr_name);
        }
            }
            grps[numgroups++] = getcpy (gr->gr_name);
        }
index 7f432ea..dae1c3b 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <h/nmh.h>
  */
 
 #include <h/nmh.h>
+#include <h/utils.h>
 
 #ifndef        MMDFONLY
 # include <h/mh.h>
 
 #ifndef        MMDFONLY
 # include <h/mh.h>
@@ -224,14 +225,8 @@ mbx_read (FILE *fp, long pos, struct drop **drops, int noisy)
        if (dp >= ep) {
            register int    curlen = dp - pp;
 
        if (dp >= ep) {
            register int    curlen = dp - pp;
 
-           cp = (struct drop *) realloc ((char *) pp,
+           cp = (struct drop *) mh_xrealloc ((char *) pp,
                                    (size_t) (len += MAXFOLDER) * sizeof(*pp));
                                    (size_t) (len += MAXFOLDER) * sizeof(*pp));
-           if (cp == NULL) {
-               if (noisy)
-                   admonish (NULL, "unable to allocate drop storage");
-               free ((char *) pp);
-               return 0;
-           }
            dp = cp + curlen, ep = (pp = cp) + len - 1;
        }
     }
            dp = cp + curlen, ep = (pp = cp) + len - 1;
        }
     }
index 1e850cb..758d308 100644 (file)
@@ -228,9 +228,8 @@ main(int argc, char **argv)
             */
            if (numfolders >= maxfolders) {
                maxfolders += MAXFOLDERS;
             */
            if (numfolders >= maxfolders) {
                maxfolders += MAXFOLDERS;
-               if (!(foldersToDo = (char **) realloc (foldersToDo,
-                       (size_t) (maxfolders * sizeof(*foldersToDo)))))
-                   adios (NULL, "unable to reallocate folder name storage");
+               foldersToDo = (char **) mh_xrealloc (foldersToDo,
+                   (size_t) (maxfolders * sizeof(*foldersToDo)));
            }
            if (*cp == '+' || *cp == '@') {
                foldersToDo[numfolders++] =
            }
            if (*cp == '+' || *cp == '@') {
                foldersToDo[numfolders++] =
@@ -655,7 +654,7 @@ AllocFolders(struct Folder **f, int *nfa, int n)
        *f = (struct Folder *) mh_xmalloc (*nfa * (sizeof(struct Folder)));
     } else {
        *nfa *= 2;
        *f = (struct Folder *) mh_xmalloc (*nfa * (sizeof(struct Folder)));
     } else {
        *nfa *= 2;
-       *f = (struct Folder *) realloc (*f, *nfa * (sizeof(struct Folder)));
+       *f = (struct Folder *) mh_xrealloc (*f, *nfa * (sizeof(struct Folder)));
     }
 }
 
     }
 }
 
index 3348ae5..d6cb5b5 100644 (file)
@@ -469,8 +469,7 @@ get_folder_info (char *fold, char *msg)
      */
     if (total_folders >= maxFolderInfo) {
        maxFolderInfo += NUMFOLDERS;
      */
     if (total_folders >= maxFolderInfo) {
        maxFolderInfo += NUMFOLDERS;
-       if ((fi = realloc (fi, maxFolderInfo * sizeof(*fi))) == NULL)
-           adios (NULL, "unable to re-allocate storage for folder info");
+       fi = mh_xrealloc (fi, maxFolderInfo * sizeof(*fi));
     }
 
     fi[i].name   = fold;
     }
 
     fi[i].name   = fold;
@@ -774,8 +773,7 @@ addfold (char *fold)
     /* if necessary, reallocate the space for folder names */
     if (foldp >= maxfolders) {
        maxfolders += NUMFOLDERS;
     /* if necessary, reallocate the space for folder names */
     if (foldp >= maxfolders) {
        maxfolders += NUMFOLDERS;
-       if ((folds = realloc (folds, maxfolders * sizeof(char *))) == NULL)
-           adios (NULL, "unable to re-allocate storage for folder names");
+       folds = mh_xrealloc (folds, maxfolders * sizeof(char *));
     }
 
     cp = getcpy (fold);
     }
 
     cp = getcpy (fold);
index 27652e0..0333722 100644 (file)
@@ -159,9 +159,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                                               (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 56d9398..03480b3 100644 (file)
@@ -264,9 +264,8 @@ do_cache:
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index af3fa55..31c24bb 100644 (file)
@@ -1644,8 +1644,7 @@ doface (struct mcomp *c1)
                if (cp) {
                    int j;
                    char *dp;
                if (cp) {
                    int j;
                    char *dp;
-                   if ((dp = realloc (cp, (unsigned) (j = len + i))) == NULL)
-                       adios (NULL, "unable to allocate face storage");
+                   dp = mh_xrealloc (cp, (unsigned) (j = len + i));
                    memcpy(dp + len, buffer, i);
                    cp = dp, len = j;
                }
                    memcpy(dp + len, buffer, i);
                    cp = dp, len = j;
                }
index 27ee05b..685a74e 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
@@ -20,6 +20,7 @@
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
+#include <h/utils.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
@@ -448,9 +449,8 @@ do_cache:
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 5084b03..4a88605 100644 (file)
@@ -89,9 +89,8 @@ main(int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage ");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index c61e917..909c440 100644 (file)
@@ -305,9 +305,8 @@ do_cache:
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 518a304..b756956 100644 (file)
@@ -251,9 +251,8 @@ do_cache:
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 9219839..298ef03 100644 (file)
@@ -252,9 +252,8 @@ do_cache:
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 0c9c8e0..df64de5 100644 (file)
--- a/uip/msh.c
+++ b/uip/msh.c
@@ -22,6 +22,7 @@
 #include <h/scansbr.h>
 #include <h/tws.h>
 #include <h/mts.h>
 #include <h/scansbr.h>
 #include <h/tws.h>
 #include <h/mts.h>
+#include <h/utils.h>
 
 #ifdef HAVE_TERMIOS_H
 # include <termios.h>
 
 #ifdef HAVE_TERMIOS_H
 # include <termios.h>
@@ -941,9 +942,7 @@ m_gMsgs (int n)
        return;
 
     nmsgs = nMsgs + n + MAXFOLDER / 2;
        return;
 
     nmsgs = nMsgs + n + MAXFOLDER / 2;
-    Msgs = (struct Msg *) realloc ((char *) Msgs, (size_t) (nmsgs + 2) * sizeof *Msgs);
-    if (Msgs == NULL)
-       padios (NULL, "unable to reallocate Msgs structure");
+    Msgs = (struct Msg *) mh_xrealloc ((char *) Msgs, (size_t) (nmsgs + 2) * sizeof *Msgs);
     memset((char *) (Msgs + nMsgs + 2), 0, (size_t) ((nmsgs - nMsgs) * sizeof *Msgs));
 
     nMsgs = nmsgs;
     memset((char *) (Msgs + nMsgs + 2), 0, (size_t) ((nmsgs - nMsgs) * sizeof *Msgs));
 
     nMsgs = nmsgs;
index 9f71b92..6f3638c 100644 (file)
@@ -119,9 +119,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 4f26bb2..8cdfa58 100644 (file)
@@ -199,9 +199,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                                               (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index d1bbafc..9d5f312 100644 (file)
@@ -1238,12 +1238,7 @@ sasl_fgetc(FILE *f)
     }
 
     if (retbufsize > size) {
     }
 
     if (retbufsize > size) {
-       buffer = realloc(buffer, retbufsize);
-       if (!buffer) {
-           snprintf(response, sizeof(response), "Error during realloc in "
-                    "read routine: %s", strerror(errno));
-           return -2;
-       }
+       buffer = mh_xrealloc(buffer, retbufsize);
        size = retbufsize;
     }
 
        size = retbufsize;
     }
 
index 4d91291..e50253a 100644 (file)
@@ -185,9 +185,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                                               (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index d92fade..244fdc9 100644 (file)
@@ -291,11 +291,9 @@ static unsigned int bufsiz=0;      /* current size of buf */
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
                int i = dst - buf;\
                int n = last_dst - buf;\
                bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
-               buf = realloc (buf, bufsiz);\
+               buf = mh_xrealloc (buf, bufsiz);\
                dst = buf + i;\
                last_dst = buf + n;\
                dst = buf + i;\
                last_dst = buf + n;\
-               if (! buf)\
-                   adios (NULL, "formataddr: couldn't get buffer space");\
                bufend = buf + bufsiz;\
            }
 
                bufend = buf + bufsiz;\
            }
 
index b25f083..b9fd80d 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
@@ -98,9 +98,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs){
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs){
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                            (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 3b56830..705ff69 100644 (file)
@@ -177,9 +177,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                    (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }
index 81ddaf7..f793b1c 100644 (file)
@@ -360,8 +360,7 @@ get_line(void)
        }
 
        if (++n >= field_size - 1) {
        }
 
        if (++n >= field_size - 1) {
-           if ((field = (char *)realloc((void *)field, field_size += 256)) == (char *)0)
-               adios(NULL, "can't grow field buffer.");
+           field = (char *)mh_xrealloc((void *)field, field_size += 256);
 
            p = field + n - 1;
        }
 
            p = field + n - 1;
        }
index 92304dc..5888d78 100644 (file)
@@ -182,9 +182,8 @@ main (int argc, char **argv)
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                    (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
            }
            msgs[nummsgs++] = cp;
        }