Commit c3c88289 c3c88289add5855a11689d9ecadf267e2cc7d62f by Sergey Poznyakoff

Removed util_[mc]alloc() in favor of x[mc]alloc().

1 parent 15a17e9d
......@@ -41,7 +41,7 @@ static node *env_cursor = NULL;
static node *
util_ll_add (node *c, int data)
{
c->next = util_malloc (sizeof (node));
c->next = xmalloc (sizeof (node));
c->data = data;
c->next->env_entry.var = NULL;
c->next->env_entry.set = 0;
......@@ -80,7 +80,7 @@ util_expand_msglist (const int argc, char **argv, int **list)
int undelete = 0;
int *ret = NULL;
/* let's try a linked list */
node *first = util_malloc (sizeof (node));
node *first = xmalloc (sizeof (node));
node *current = first;
first->next = NULL;
......@@ -150,7 +150,7 @@ util_expand_msglist (const int argc, char **argv, int **list)
{
/* all messages */
util_ll_free (first);
current = first = util_malloc (sizeof (node));
current = first = xmalloc (sizeof (node));
for (i = 1; i <= total; i++)
current = util_ll_add (current, i);
i = argc + 1;
......@@ -255,13 +255,13 @@ util_expand_msglist (const int argc, char **argv, int **list)
if (!lc)
{
ret = util_calloc (1, sizeof (int));
ret = xcalloc (1, sizeof (int));
ret [0] = cursor;
lc = 1;
}
else
{
ret = util_malloc (lc * sizeof (int));
ret = xmalloc (lc * sizeof (int));
lc = 0;
for (current = first; current->next != NULL; current = current->next)
ret [lc++] = current->data;
......@@ -494,7 +494,7 @@ util_find_env (const char *variable)
if (environment == NULL)
{
environment = util_malloc (sizeof (node));
environment = xmalloc (sizeof (node));
environment->env_entry.var = NULL;
environment->env_entry.set = 0;
environment->env_entry.value = NULL;
......@@ -802,7 +802,7 @@ util_escape_percent (char **str)
return; /* nothing to do */
/* expand the string */
newstr = util_malloc (strlen (*str) + 1 + count);
newstr = xmalloc (strlen (*str) + 1 + count);
/* and escape percent signs */
p = newstr;
......@@ -1013,25 +1013,3 @@ util_tempfile(char **namep)
return fd;
}
void *
util_malloc (size_t size)
{
void *p = malloc (size);
if (!p)
{
util_error ("not enough memory (allocating %d bytes)", size);
abort ();
}
return p;
}
void *
util_calloc (size_t nitems, size_t size)
{
void *p;
size *= nitems;
p = util_malloc (size);
memset (p, 0, size);
return p;
}
......