From: Davidlohr Bueso Date: Mon, 29 Nov 2010 12:27:18 +0000 (-0300) Subject: last: use xalloc lib X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eecb3c83ce12de156a03e20892e553f660cef1bb;p=util-linux last: use xalloc lib Signed-off-by: Davidlohr Bueso --- diff --git a/login-utils/last.c b/login-utils/last.c index 564e05ca..293a0fd6 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -49,6 +49,7 @@ #include "pathnames.h" #include "nls.h" +#include "xalloc.h" #define SECDAY (24*60*60) /* seconds in a day */ #define NO 0 /* false/no */ @@ -376,10 +377,7 @@ static void addarg(int type, char *arg) { register ARG *cur; - if (!(cur = (ARG *)malloc((unsigned int)sizeof(ARG)))) { - fputs(_("last: malloc failure.\n"), stderr); - exit(1); - } + cur = xmalloc(sizeof(ARG)); cur->next = arglist; cur->type = type; cur->name = arg; @@ -394,10 +392,7 @@ TTY * addtty(char *ttyname) { register TTY *cur; - if (!(cur = (TTY *)malloc((unsigned int)sizeof(TTY)))) { - fputs(_("last: malloc failure.\n"), stderr); - exit(1); - } + cur = xmalloc(sizeof(TTY)); cur->next = ttylist; cur->logout = currentout; memcpy(cur->tty, ttyname, LMAX); @@ -445,10 +440,7 @@ ttyconv(char *arg) { */ if (strlen(arg) == 2) { /* either 6 for "ttyxx" or 8 for "console" */ - if (!(mval = malloc((unsigned int)8))) { - fputs(_("last: malloc failure.\n"), stderr); - exit(1); - } + mval = xmalloc(8); if (!strcmp(arg, "co")) (void)strcpy(mval, "console"); else {