X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fmf.c;h=518a184dd37f40f7d8d8e1c36fb635311a3ffc6d;hb=23f854c962a161cc8ed982b23183600df376e818;hp=27c06bb1fb203b16ef1159751f88de7ec4a3f99e;hpb=c6e5547c9da87292c554449e8b91d83bac70b7be;p=mmh diff --git a/sbr/mf.c b/sbr/mf.c index 27c06bb..518a184 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -12,6 +12,7 @@ #include #include #include +#include /* * static prototypes @@ -42,8 +43,8 @@ getcpy (char *s) for(;;) pause(); } - if ((p = malloc ((size_t) (strlen (s) + 2)))) - strcpy (p, s); + p = mh_xmalloc ((size_t) (strlen (s) + 2)); + strcpy (p, s); return p; } @@ -56,8 +57,8 @@ add (char *s1, char *s2) if (!s2) return getcpy (s1); - if ((p = malloc ((size_t) (strlen (s1) + strlen (s2) + 2)))) - sprintf (p, "%s%s", s2, s1); + p = mh_xmalloc ((size_t) (strlen (s1) + strlen (s2) + 2)); + sprintf (p, "%s%s", s2, s1); free (s2); return p; } @@ -934,8 +935,7 @@ mfgets (FILE *in, char **bp) static char *pp = NULL; if (pp == NULL) - if (!(pp = malloc ((size_t) (len = BUFSIZ)))) - return NOTOK; + pp = mh_xmalloc ((size_t) (len = BUFSIZ)); for (ep = (cp = pp) + len - 2;;) { switch (i = getc (in)) { @@ -975,13 +975,8 @@ mfgets (FILE *in, char **bp) 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; } } }