OSDN Git Service

Use gnulib xmalloc() and xrealloc().
authorDavid Cantrell <dcantrel@mortise.boston.redhat.com>
Wed, 9 May 2007 19:15:47 +0000 (15:15 -0400)
committerOtavio Salvador <otavio@ossystems.com.br>
Mon, 14 May 2007 16:22:06 +0000 (13:22 -0300)
parted/table.c

index c44db10..8768a92 100644 (file)
@@ -47,6 +47,7 @@
         size_t strnlen (const char *, size_t);
 #endif
 
+#include "xalloc.h"
 #include "strlist.h"
 
 
@@ -191,16 +192,14 @@ static void table_render_row (Table* t, int rownum, int ncols, wchar_t** s)
         len += wcslen(COLSUFFIX);
 
         newsize = (wcslen(*s) + len + 1) * sizeof(wchar_t);
-        *s = (wchar_t *) realloc (*s, newsize);
-        assert(*s != NULL);
+        *s = xrealloc (*s, newsize);
 
         for (i = 0; i < ncols; ++i)
         {
                 int j;
                 int nspaces = max(t->widths[i] - wcswidth(row[i], MAX_WIDTH),
                                   0);
-                wchar_t* pad = malloc ( (nspaces + 1) * sizeof(wchar_t) );
-                assert(pad != NULL);
+                wchar_t* pad = xmalloc ((nspaces + 1) * sizeof(wchar_t));
 
                 for (j = 0; j < nspaces; ++j)
                        pad[j] = L' ';