X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fvfgets.c;h=3a376e10d6614fa3c1274359d5a78dd8dc7562a0;hb=56a34bc502bde807ab722ee5f20d4db2901a5b23;hp=39cfaa276de7e5291b6dfe6813f484bfc80956cb;hpb=6c42153ad9362cc676ea66563bf400d7511b3b68;p=mmh diff --git a/sbr/vfgets.c b/sbr/vfgets.c index 39cfaa2..3a376e1 100644 --- a/sbr/vfgets.c +++ b/sbr/vfgets.c @@ -2,14 +2,13 @@ /* * vfgets.c -- virtual fgets * - * $Id$ - * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ #include +#include #define QUOTE '\\' @@ -23,8 +22,7 @@ vfgets (FILE *in, char **bp) static char *pp = NULL; if (pp == NULL) - if (!(pp = malloc ((size_t) (len = BUFSIZ)))) - adios (NULL, "unable to allocate string storage"); + pp = mh_xmalloc ((size_t) (len = BUFSIZ)); for (ep = (cp = pp) + len - 1;;) { if (fgets (cp, ep - cp + 1, in) == NULL) { @@ -66,12 +64,9 @@ wrong_guess: 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; } } }