From: Davidlohr Bueso <dave@xxxxxxx> Date: Fri, 22 Oct 2010 12:25:46 -0300 Subject: [PATCH 5/7] ul: use xalloc for memory allocation Signed-off-by: Davidlohr Bueso <dave@xxxxxxx> --- text-utils/ul.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-) diff --git a/text-utils/ul.c b/text-utils/ul.c index 4601e3c..9ddb0ea 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -49,8 +49,9 @@ #include <signal.h> /* for signal() */ #include <err.h> #include <errno.h> -#include "nls.h" +#include "nls.h" +#include "xalloc.h" #include "widechar.h" #ifdef HAVE_WIDECHAR @@ -428,9 +429,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 */ @@ -596,9 +595,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); } } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html