]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: use xalloc lib
authorSami Kerola <kerolasa@iki.fi>
Sat, 2 Apr 2011 16:30:40 +0000 (18:30 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Apr 2011 08:59:17 +0000 (10:59 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/column.c

index fdd28640daf3fa9f7d4e5fd4f26cb5c600bfb95b..ffc91df6539fa3fd397970c01268d3f28fbea4ba 100644 (file)
 
 #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);
 }