struct idcache *nc, *x;
int w = 0;
- nc = calloc(1, sizeof(*nc));
- if (!nc)
- goto alloc_err;
+ nc = xcalloc(1, sizeof(*nc));
nc->id = id;
if (name) {
}
/* note, we ignore names with non-printable widechars */
if (w > 0)
- nc->name = strdup(name);
+ nc->name = xstrdup(name);
else if (asprintf(&nc->name, "%lu", id) == -1)
nc->name = NULL;
- if (!nc->name)
- goto alloc_err;
for (x = *ic; x && x->next; x = x->next);
*width = *width < w ? w : *width;
return;
-alloc_err:
- err(EXIT_FAILURE, _("out of memory?"));
}
static void
return NULL;
len = strlen(dirname);
- path = malloc(len + sizeof(DOTDOTDIR));
- if (!path)
- err(EXIT_FAILURE, _("out of memory?"));
+ path = xmalloc(len + sizeof(DOTDOTDIR));
memcpy(path, dirname, len);
memcpy(path + len, DOTDOTDIR, sizeof(DOTDOTDIR));
if (!fname)
return NULL;
- nm = calloc(1, sizeof(*nm));
- if (!nm)
- err(EXIT_FAILURE, _("out of memory?"));
+ nm = xcalloc(1, sizeof(*nm));
if (parent)
parent->next = nm;
nm->level = lev;
- nm->name = strdup(fname);
- if (!nm->name)
- err(EXIT_FAILURE, _("out of memory?"));
+ nm->name = xstrdup(fname);
nm->noent = (lstat(path, &nm->st) == -1);
if (nm->noent)
nm = parent;
level = parent->level + 1;
}
- path = strdup(orgpath);
- if (!path)
- err(EXIT_FAILURE, _("out of memory?"));
+ path = xstrdup(orgpath);
fname = path + start;
/* root directory */