diff options
author | Davidlohr Bueso | 2010-10-22 17:22:09 +0200 |
---|---|---|
committer | Karel Zak | 2010-11-01 14:03:08 +0100 |
commit | f3a342a429b0576efeaf875bfb102f5b55f7c9b4 (patch) | |
tree | dbff1364318537f825ef403f520372e8b66f171d /text-utils | |
parent | mount: use utimensat(AT_FDCWD) rather than open()+futimens() (diff) | |
download | kernel-qcow2-util-linux-f3a342a429b0576efeaf875bfb102f5b55f7c9b4.tar.gz kernel-qcow2-util-linux-f3a342a429b0576efeaf875bfb102f5b55f7c9b4.tar.xz kernel-qcow2-util-linux-f3a342a429b0576efeaf875bfb102f5b55f7c9b4.zip |
pg: use xalloc for memory allocation
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/pg.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/text-utils/pg.c b/text-utils/pg.c index 24c122177..68275238f 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -60,6 +60,7 @@ #include <term.h> #include "nls.h" +#include "xalloc.h" #include "widechar.h" #define READBUF LINE_MAX /* size of input buffer */ @@ -213,21 +214,6 @@ quit(int status) } /* - * Memory allocator including check. - */ -static char * -smalloc(size_t s) -{ - char *m = (char *)malloc(s); - if (m == NULL) { - const char *p = _("Out of memory\n"); - write(2, p, strlen(p)); - quit(++exitstatus); - } - return m; -} - -/* * Usage message and similar routines. */ static void @@ -549,7 +535,7 @@ endline(unsigned col, char *s) static void cline(void) { - char *buf = (char *)smalloc(ttycols + 2); + char *buf = xmalloc(ttycols + 2); memset(buf, ' ', ttycols + 2); buf[0] = '\r'; buf[ttycols + 1] = '\r'; @@ -601,7 +587,7 @@ getcount(char *cmdstr) if (*cmdstr == '\0') return 1; - buf = (char *)smalloc(strlen(cmdstr) + 1); + buf = xmalloc(strlen(cmdstr) + 1); strcpy(buf, cmdstr); if (cmd.key != '\0') { if (cmd.key == '/' || cmd.key == '?' || cmd.key == '^') { |