summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
diff options
context:
space:
mode:
authorSami Kerola2011-04-02 18:30:40 +0200
committerKarel Zak2011-04-06 10:59:17 +0200
commita29e40cad5cbb5edf219d42d80acdd4f62a28a8c (patch)
treecdc9e6020221466b9e938051063cb997d7a97021 /text-utils/column.c
parentrev: mention long options in man page (diff)
downloadkernel-qcow2-util-linux-a29e40cad5cbb5edf219d42d80acdd4f62a28a8c.tar.gz
kernel-qcow2-util-linux-a29e40cad5cbb5edf219d42d80acdd4f62a28a8c.tar.xz
kernel-qcow2-util-linux-a29e40cad5cbb5edf219d42d80acdd4f62a28a8c.zip
column: use xalloc lib
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r--text-utils/column.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/text-utils/column.c b/text-utils/column.c
index fdd28640d..ffc91df65 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -53,13 +53,14 @@
#include "widechar.h"
#include "c.h"
+#include "xalloc.h"
#ifdef HAVE_WIDECHAR
#define wcs_width(s) wcswidth(s,wcslen(s))
static wchar_t *mbs_to_wcs(const char *);
#else
#define wcs_width(s) strlen(s)
-#define mbs_to_wcs(s) strdup(s)
+#define mbs_to_wcs(s) xstrdup(s)
static char *mtsafe_strtok(char *, const char *, char **);
#define wcstok mtsafe_strtok
#endif
@@ -282,12 +283,10 @@ maketbl()
(cols[coloff] = wcstok(p, separator, &wcstok_state)) != NULL;
p = NULL) {
if (++coloff == maxcols) {
- cols = realloc(cols, ((u_int)maxcols + DEFCOLS)
+ cols = xrealloc(cols, ((u_int)maxcols + DEFCOLS)
* sizeof(wchar_t *));
- lens = realloc(lens, ((u_int)maxcols + DEFCOLS)
+ lens = xrealloc(lens, ((u_int)maxcols + DEFCOLS)
* sizeof(int));
- if (!cols || !lens)
- err(EXIT_FAILURE, _("out of memory?"));
memset((char *)lens + maxcols * sizeof(int),
0, DEFCOLS * sizeof(int));
maxcols += DEFCOLS;
@@ -346,9 +345,7 @@ input(fp)
maxlength = len;
if (entries == maxentry) {
maxentry += DEFNUM;
- list = realloc(list, (u_int)maxentry * sizeof(wchar_t *));
- if (!list)
- err(EXIT_FAILURE, _("out of memory?"));
+ list = xrealloc(list, (u_int)maxentry * sizeof(wchar_t *));
}
list[entries++] = wcsdup(buf);
}
@@ -403,8 +400,7 @@ emalloc(size)
{
char *p;
- if (!(p = malloc(size)))
- err(EXIT_FAILURE, _("out of memory?"));
+ p = xmalloc(size);
memset(p, 0, size);
return (p);
}