From: Davidlohr Bueso Date: Fri, 22 Oct 2010 15:25:46 +0000 (-0300) Subject: ul: use xalloc for memory allocation X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0961db21f912511ed6ac7fee02e26b40efe0d8c;p=util-linux ul: use xalloc for memory allocation Signed-off-by: Davidlohr Bueso --- diff --git a/text-utils/ul.c b/text-utils/ul.c index ab0a6e77..30f24e9d 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -49,8 +49,9 @@ #include /* for signal() */ #include #include -#include "nls.h" +#include "nls.h" +#include "xalloc.h" #include "widechar.h" #ifdef HAVE_WIDECHAR @@ -426,9 +427,7 @@ void initbuf(void) { if (obuf == NULL) { /* First time. */ obuflen = INITBUF; - obuf = malloc(sizeof(struct CHAR) * obuflen); - if (obuf == NULL) - err(EXIT_FAILURE, _("unable to allocate buffer")); + obuf = xmalloc(sizeof(struct CHAR) * obuflen); } /* assumes NORMAL == 0 */ @@ -594,9 +593,7 @@ needcol(int col) { : obuflen * 2; /* Now we can try to expand obuf. */ - obuf = realloc(obuf, sizeof(struct CHAR) * obuflen); - if (obuf == NULL) - err(EXIT_FAILURE, _("growing buffer failed")); + obuf = xrealloc(obuf, sizeof(struct CHAR) * obuflen); } }