#include <string.h>
#include <stdlib.h>
+#include "libbb/libbb.h"
void active_list_init(struct active_list *ptr) {
INIT_LIST_HEAD(&ptr->node);
}
struct active_list * active_list_head_new() {
- struct active_list * head = calloc(1, sizeof(struct active_list));
+ struct active_list * head = xcalloc(1, sizeof(struct active_list));
active_list_init(head);
return head;
}
buf_len = strlen(buf);
if (line) {
line_size += buf_len;
- line = realloc(line, line_size);
- if (line == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- break;
- }
+ line = xrealloc(line, line_size);
strcat(line, buf);
} else {
line_size = buf_len + 1;
char *md5sum_hex;
unsigned char md5sum_bin[md5sum_bin_len];
- md5sum_hex = calloc(1, md5sum_hex_len + 1);
- if (md5sum_hex == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ md5sum_hex = xcalloc(1, md5sum_hex_len + 1);
file = fopen(file_name, "r");
if (file == NULL) {
char *sha256sum_hex;
unsigned char sha256sum_bin[sha256sum_bin_len];
- sha256sum_hex = calloc(1, sha256sum_hex_len + 1);
- if (sha256sum_hex == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ sha256sum_hex = xcalloc(1, sha256sum_hex_len + 1);
file = fopen(file_name, "r");
if (file == NULL) {
--picker;
hash->n_entries = *picker;
- hash->entries = (hash_entry_t *)calloc(hash->n_entries, sizeof(hash_entry_t));
- if (hash->entries == NULL) {
- fprintf(stderr, "%s: Out of memory.\n", __FUNCTION__);
- return ENOMEM;
- }
+ hash->entries = xcalloc(hash->n_entries, sizeof(hash_entry_t));
+
return 0;
}
return 0;
}
}
- hash_entry->next = (hash_entry_t *)calloc(1, sizeof(hash_entry_t));
- if (!hash_entry->next) {
- return -ENOMEM;
- }
+ hash_entry->next = xcalloc(1, sizeof(hash_entry_t));
hash_entry = hash_entry->next;
hash_entry->next = NULL;
}
#include "nv_pair.h"
#include "void_list.h"
#include "nv_pair_list.h"
-
+#include "libbb/libbb.h"
int nv_pair_list_init(nv_pair_list_t *list)
{
int err;
/* freed in nv_pair_list_deinit */
- nv_pair_t *nv_pair = calloc(1, sizeof(nv_pair_t));
-
- if (nv_pair == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ nv_pair_t *nv_pair = xcalloc(1, sizeof(nv_pair_t));
nv_pair_init(nv_pair, name, value);
err = void_list_append((void_list_t *) list, nv_pair);
opkg_package_t *p;
- p = calloc (1, sizeof (opkg_package_t));
+ p = xcalloc(1, sizeof (opkg_package_t));
return p;
}
opkg_t *opkg;
int err;
- opkg = calloc (1, sizeof (opkg_t));
+ opkg = xcalloc(1, sizeof (opkg_t));
- opkg->args = calloc (1, sizeof (args_t));
+ opkg->args = xcalloc(1, sizeof (args_t));
err = args_init (opkg->args);
if (err)
{
return NULL;
}
- opkg->conf = calloc (1, sizeof (opkg_conf_t));
+ opkg->conf = xcalloc(1, sizeof (opkg_conf_t));
err = opkg_conf_init (opkg->conf, opkg->args);
if (err)
{
char *newpath;
int gen;
- ctx = calloc (1, sizeof (*ctx));
+ ctx = xcalloc(1, sizeof (*ctx));
ctx->oldpath = xstrdup(getenv("PATH"));
sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
available = pkg_vec_alloc();
pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
for (i=0; i < argc; i++) {
- pkg_name = calloc(1, strlen(argv[i])+2);
+ pkg_name = xcalloc(1, strlen(argv[i])+2);
strcpy(pkg_name,argv[i]);
for (a=0; a < available->len; a++) {
pkg = available->pkgs[a];
{ NULL }
};
- *options = (opkg_option_t *)calloc(1, sizeof(tmp));
- if ( options == NULL ){
- fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
- return -1;
- }
-
+ *options = xcalloc(1, sizeof(tmp));
memcpy(*options, tmp, sizeof(tmp));
return 0;
};
pkg_hash_init("pkg-hash", &conf->pkg_hash, OPKG_CONF_DEFAULT_HASH_LEN);
hash_table_init("file-hash", &conf->file_hash, OPKG_CONF_DEFAULT_HASH_LEN);
hash_table_init("obs-file-hash", &conf->obs_file_hash, OPKG_CONF_DEFAULT_HASH_LEN);
- lists_dir=(char *)malloc(1);
+ lists_dir=xmalloc(1);
lists_dir[0]='\0';
if (args->conf_file) {
struct stat stat_buf;
}
if (strlen(lists_dir)<=1 ){
- lists_dir = realloc(lists_dir,strlen(OPKG_CONF_LISTS_DIR)+2);
+ lists_dir = xrealloc(lists_dir,strlen(OPKG_CONF_LISTS_DIR)+2);
sprintf (lists_dir,"%s",OPKG_CONF_LISTS_DIR);
}
lists_dir = tmp;
}
- pending_dir = calloc(1, strlen(lists_dir)+strlen("/pending")+5);
+ pending_dir = xcalloc(1, strlen(lists_dir)+strlen("/pending")+5);
snprintf(pending_dir,strlen(lists_dir)+strlen("/pending") ,"%s%s",lists_dir,"/pending");
conf->lists_dir = xstrdup(lists_dir);
} else if (strcmp(type, "dest") == 0) {
nv_pair_list_append(tmp_dest_nv_pair_list, name, value);
} else if (strcmp(type, "lists_dir") == 0) {
- *lists_dir = realloc(*lists_dir,strlen(value)+1);
- if (*lists_dir == NULL) {
- opkg_message(conf, OPKG_ERROR, "ERROR: Not enough memory\n");
- free(options);
- return EINVAL;
- }
+ *lists_dir = xrealloc(*lists_dir,strlen(value)+1);
sprintf (*lists_dir,"%s",value);
} else if (strcmp(type, "arch") == 0) {
opkg_message(conf, OPKG_INFO, "supported arch %s priority (%s)\n", name, value);
if (found)
continue;
d_str = old_pkg->depends_str[i];
- buf = calloc (1, strlen (d_str) + 1);
+ buf = xcalloc(1, strlen (d_str) + 1);
j=0;
while (d_str[j] != '\0' && d_str[j] != ' ') {
buf[j]=d_str[j];
++j;
}
buf[j]='\0';
- buf = realloc (buf, strlen (buf) + 1);
+ buf = xrealloc (buf, strlen (buf) + 1);
p = pkg_hash_fetch_installed_by_name (&conf->pkg_hash, buf);
if (!p) {
fprintf(stderr, "The pkg %s had been removed!!\n", buf);
#include "file_util.h"
#include "sprintf_alloc.h"
#include "str_util.h"
+#include "libbb/libbb.h"
/*
* Returns number of the number of packages depending on the packages provided by this package.
/* if caller requested the set of installed dependents */
if (pdependents) {
int p = 0;
- abstract_pkg_t **dependents = (abstract_pkg_t **)calloc((n_installed_dependents+1), sizeof(abstract_pkg_t *));
-
- if ( dependents == NULL ){
- fprintf(stderr,"%s Unable to allocate memory. REPORT THIS BUG IN BUGZILLA PLEASE\n", __FUNCTION__);
- return -1;
- }
+ abstract_pkg_t **dependents = xcalloc((n_installed_dependents+1), sizeof(abstract_pkg_t *));
*pdependents = dependents;
for (i = 0; i <= nprovides; i++) {
int x = 0;
pkg_t *p;
d_str = pkg->depends_str[i];
- buffer = calloc (1, strlen (d_str) + 1);
- if (!buffer)
- {
- fprintf(stderr,"%s Unable to allocate memory.\n", __FUNCTION__);
- return -1;
- }
+ buffer = xcalloc(1, strlen (d_str) + 1);
while (d_str[x] != '\0' && d_str[x] != ' ')
{
++x;
}
buffer[x] = '\0';
- buffer = realloc (buffer, strlen (buffer) + 1);
+ buffer = xrealloc (buffer, strlen (buffer) + 1);
p = pkg_hash_fetch_installed_by_name (&conf->pkg_hash, buffer);
/* if the package is not installed, this could have been a circular
int count = 0;
size_t size = 512;
- buf = calloc (1, size);
+ buf = xcalloc(1, size);
while (fgets(buf, size, fp)) {
while (strlen (buf) == (size - 1)
&& buf[size-2] != '\n') {
size_t o = size - 1;
size *= 2;
- buf = realloc (buf, size);
+ buf = xrealloc (buf, size);
if (fgets (buf + o, size - o, fp) == NULL)
break;
}
if(!(count % 50))
- raw = realloc(raw, (count + 50) * sizeof(char *));
+ raw = xrealloc(raw, (count + 50) * sizeof(char *));
if((scout = strchr(buf, '\n')))
*scout = '\0';
raw[count++] = xstrdup(buf);
}
- raw = realloc(raw, (count + 1) * sizeof(char *));
+ raw = xrealloc(raw, (count + 1) * sizeof(char *));
raw[count] = NULL;
free (buf);
char *new;
char *dest, *src, *end;
- new = calloc(1, strlen(line) + 1);
- if ( new == NULL ){
- fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
- return NULL;
- }
+ new = xcalloc(1, strlen(line) + 1);
dest = new, src = line, end = line + (strlen(line) - 1);
/* remove it from the front */
{
struct errlist *e;
- e = calloc(1, sizeof(struct errlist));
- if (e == NULL) {
- fprintf(stderr, "%s: calloc: %s\n",
- __FUNCTION__, strerror(errno));
- return;
- }
-
+ e = xcalloc(1, sizeof(struct errlist));
e->errmsg = xstrdup(msg);
e->next = NULL;
{
pkg_t *pkg;
- pkg = calloc(1, sizeof(pkg_t));
+ pkg = xcalloc(1, sizeof(pkg_t));
if (pkg == NULL) {
fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
return NULL;
{
abstract_pkg_t * ab_pkg;
- ab_pkg = calloc(1, sizeof(abstract_pkg_t));
+ ab_pkg = xcalloc(1, sizeof(abstract_pkg_t));
if (ab_pkg == NULL) {
fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
}
pkg->installed_files = str_list_alloc();
- if (pkg->installed_files == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
/* For uninstalled packages, get the file list directly from the package.
For installed packages, look at the package.list file in the database.
len += strlen(pkg_state_flag_map[i].str) + 1;
}
}
- str = malloc(len);
- if ( str == NULL ) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ str = xmalloc(len);
str[0] = 0;
for (i=0; i < ARRAY_SIZE(pkg_state_flag_map); i++) {
if (sf & pkg_state_flag_map[i].value) {
if(!newstuff)
return oldstuff;
-
+
while(oldstuff && oldstuff[oldlen]) oldlen++;
while(newstuff && newstuff[newlen]) newlen++;
-
- result = (char **)realloc(oldstuff, sizeof(char *) * (oldlen + newlen + 1));
- if (result == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
-
+
+ result = xrealloc(oldstuff, sizeof(char *) * (oldlen + newlen + 1));
+
for(i = oldlen, j = 0; i < (oldlen + newlen); i++, j++)
*(result + i) = *(newstuff + j);
-
+
*(result + i) = NULL;
return result;
}
-
+
/*
* a kinda kludgy way to back out depends str from two different arrays (reg'l'r 'n pre)
* this is null terminated, no count is carried around
while(the_lost && the_lost[count]) count++;
count++; /* need one to hold the null */
- resized = (char **)realloc(the_lost, sizeof(char *) * (count + 1));
- if (resized == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ resized = xrealloc(the_lost, sizeof(char *) * (count + 1));
resized[count - 1] = xstrdup(depend_str);
resized[count] = NULL;
if (pkg->provides)
return 0;
- pkg->provides = (abstract_pkg_t **)calloc((pkg->provides_count + 1), sizeof(abstract_pkg_t *));
- if (pkg->provides == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return -1 ;
- }
+ pkg->provides = xcalloc((pkg->provides_count + 1), sizeof(abstract_pkg_t *));
pkg->provides[0] = ab_pkg;
// if (strcmp(ab_pkg->name, pkg->name))
if (!pkg->conflicts_count)
return 0;
- conflicts = pkg->conflicts = calloc(pkg->conflicts_count, sizeof(compound_depend_t));
- if (conflicts == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return -1;
- }
+ conflicts = pkg->conflicts = xcalloc(pkg->conflicts_count, sizeof(compound_depend_t));
for (i = 0; i < pkg->conflicts_count; i++) {
conflicts->type = CONFLICTS;
parseDepends(conflicts, hash,
if (!pkg->replaces_count)
return 0;
- pkg->replaces = (abstract_pkg_t **)calloc(pkg->replaces_count, sizeof(abstract_pkg_t *));
- if (pkg->replaces == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return -1;
- }
+ pkg->replaces = xcalloc(pkg->replaces_count, sizeof(abstract_pkg_t *));
for(i = 0; i < pkg->replaces_count; i++){
abstract_pkg_t *old_abpkg = ensure_abstract_pkg_by_name(hash, pkg->replaces_str[i]);
j = 0;
if (!old_abpkg->replaced_by)
old_abpkg->replaced_by = abstract_pkg_vec_alloc();
- if ( old_abpkg->replaced_by == NULL ){
- return -1;
- }
/* if a package pkg both replaces and conflicts old_abpkg,
* then add it to the replaced_by vector so that old_abpkg
* will be upgraded to ab_pkg automatically */
if (0 && pkg->pre_depends_count)
fprintf(stderr, "pkg=%s pre_depends_count=%d depends_count=%d\n",
pkg->name, pkg->pre_depends_count, pkg->depends_count);
- depends = pkg->depends = calloc(count, sizeof(compound_depend_t));
- if (depends == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return -1;
- }
-
+ depends = pkg->depends = xcalloc(count, sizeof(compound_depend_t));
for(i = 0; i < pkg->pre_depends_count; i++){
parseDepends(depends, hash, pkg->pre_depends_str[i]);
for (j = 0; j < depends->possibility_count; j++){
ab_depend = depends->possibilities[j]->pkg;
if(!ab_depend->depended_upon_by)
- ab_depend->depended_upon_by = (abstract_pkg_t **)calloc(1, sizeof(abstract_pkg_t *));
+ ab_depend->depended_upon_by = xcalloc(1, sizeof(abstract_pkg_t *));
temp = ab_depend->depended_upon_by;
othercount = 1;
}
*temp = ab_pkg;
- ab_depend->depended_upon_by = (abstract_pkg_t **)realloc(ab_depend->depended_upon_by,
+ ab_depend->depended_upon_by = xrealloc(ab_depend->depended_upon_by,
(othercount + 1) * sizeof(abstract_pkg_t *));
/* the array may have moved */
temp = ab_depend->depended_upon_by + othercount;
static depend_t * depend_init(void)
{
- depend_t * d = (depend_t *)calloc(1, sizeof(depend_t));
- if ( d==NULL ){
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ depend_t * d = xcalloc(1, sizeof(depend_t));
d->constraint = NONE;
d->version = NULL;
d->pkg = NULL;
compound_depend->type = DEPEND;
compound_depend->possibility_count = num_of_ors + 1;
- possibilities = (depend_t **)calloc((num_of_ors + 1), sizeof(depend_t *) );
- if (!possibilities)
- return -ENOMEM;
+ possibilities = xcalloc((num_of_ors + 1), sizeof(depend_t *) );
compound_depend->possibilities = possibilities;
src = depend_str;
for(i = 0; i < num_of_ors + 1; i++){
possibilities[i] = depend_init();
- if (!possibilities[i])
- return -ENOMEM;
/* gobble up just the name first */
dest = buffer;
while(*src &&
#include "pkg_dest.h"
#include "void_list.h"
#include "pkg_dest_list.h"
+#include "libbb/libbb.h"
int pkg_dest_list_elt_init(pkg_dest_list_elt_t *elt, pkg_dest_t *data)
{
int err;
pkg_dest_t *pkg_dest;
- /* freed in plg_dest_list_deinit */
- pkg_dest = calloc(1, sizeof(pkg_dest_t));
- if (pkg_dest == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ /* freed in pkg_dest_list_deinit */
+ pkg_dest = xcalloc(1, sizeof(pkg_dest_t));
pkg_dest_init(pkg_dest, name, root_dir,lists_dir);
err = void_list_append((void_list_t *) list, pkg_dest);
if (err)
*err = 0;
- if (matching_apkgs == NULL || providers == NULL ||
- apkg == NULL || apkg->provided_by == NULL || (apkg->provided_by->len == 0))
+ if (apkg == NULL || apkg->provided_by == NULL || (apkg->provided_by->len == 0))
return NULL;
opkg_message(conf, OPKG_DEBUG, "best installation candidate for %s\n", apkg->name);
return NULL;
}
while(raw && *raw){
- depends = (char **)realloc(depends, sizeof(char *) * (line_count + 1));
+ depends = xrealloc(depends, sizeof(char *) * (line_count + 1));
while(isspace(*raw)) raw++;
if (!pkg->version)
{
- pkg->version= calloc(1, strlen(raw)+1);
- if ( pkg->version == NULL ) {
- fprintf(stderr, "%s: out of memory \n", __FUNCTION__);
- return ENOMEM;
- }
- strcpy(pkg->version, raw);
+ pkg->version= xcalloc(1, strlen(raw)+1);
+ strcpy(pkg->version, raw);
}
hyphen= strrchr(pkg->version,'-');
pkg->priority = parseGenericFieldType("Priority", *lines);
else if(isGenericFieldType("Provides", *lines)){
/* Here we add the internal_use to align the off by one problem between provides_str and provides */
- provide = (char * ) calloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
+ provide = xcalloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
if ( alterProvidesLine(*lines,provide) ){
return EINVAL;
}
case ' ':
if(reading_description) {
/* we already know it's not blank, so the rest of description */
- pkg->description = realloc(pkg->description,
+ pkg->description = xrealloc(pkg->description,
strlen(pkg->description)
+ 1 + strlen(*lines) + 1);
strcat(pkg->description, "\n");
if ( pkg_false_provides==1)
{
pkg->provides_count = 1;
- pkg->provides_str = calloc (1, sizeof (char*));
+ pkg->provides_str = xcalloc(1, sizeof (char*));
pkg->provides_str[0] = xstrdup("opkg_internal_use_only");
}
#include "pkg_src_list.h"
#include "void_list.h"
+#include "libbb/libbb.h"
int pkg_src_list_init(pkg_src_list_t *list)
{
int err;
/* freed in pkg_src_list_deinit */
- pkg_src_t *pkg_src = calloc(1, sizeof(pkg_src_t));
-
- if (pkg_src == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ pkg_src_t *pkg_src = xcalloc(1, sizeof(pkg_src_t));
pkg_src_init(pkg_src, name, base_url, extra_data, gzip);
err = void_list_append((void_list_t *) list, pkg_src);
#include "xregex.h"
#include "pkg.h"
#include "opkg_message.h"
+#include "libbb/libbb.h"
pkg_vec_t * pkg_vec_alloc(void)
{
- pkg_vec_t * vec = (pkg_vec_t *)calloc(1, sizeof(pkg_vec_t));
- if (!vec) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ pkg_vec_t * vec = xcalloc(1, sizeof(pkg_vec_t));
vec->pkgs = NULL;
vec->len = 0;
void pkg_vec_insert(pkg_vec_t *vec, const pkg_t *pkg)
{
- pkg_t **tmp;
- tmp = realloc(vec->pkgs, (vec->len + 1) * sizeof(pkg_t *));
- if (tmp == NULL) {
- fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(errno));
- return;
- }
- vec->pkgs = tmp;
+ vec->pkgs = xrealloc(vec->pkgs, (vec->len + 1) * sizeof(pkg_t *));
vec->pkgs[vec->len] = (pkg_t *)pkg;
vec->len++;
}
abstract_pkg_vec_t * abstract_pkg_vec_alloc(void)
{
abstract_pkg_vec_t * vec ;
- vec = (abstract_pkg_vec_t *)calloc(1, sizeof(abstract_pkg_vec_t));
- if (!vec) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ vec = xcalloc(1, sizeof(abstract_pkg_vec_t));
vec->pkgs = NULL;
vec->len = 0;
*/
void abstract_pkg_vec_insert(abstract_pkg_vec_t *vec, abstract_pkg_t *pkg)
{
- abstract_pkg_t **tmp;
- tmp = realloc(vec->pkgs, (vec->len + 1) * sizeof(abstract_pkg_t *));
- if (tmp == NULL) {
- fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(errno));
- return;
- }
- vec->pkgs = tmp;
+ vec->pkgs = xrealloc(vec->pkgs, (vec->len + 1) * sizeof(abstract_pkg_t *));
vec->pkgs[vec->len] = pkg;
vec->len++;
}
#include <stdarg.h>
#include "sprintf_alloc.h"
+#include "libbb/libbb.h"
int sprintf_alloc(char **str, const char *fmt, ...)
{
va_list ap;
- char *new_str;
int n, size = 100;
if (!str) {
/* ripped more or less straight out of PRINTF(3) */
- if ((new_str = calloc(1, size)) == NULL)
- return -1;
+ *str = xcalloc(1, size);
- *str = new_str;
while(1) {
va_start(ap, fmt);
- n = vsnprintf (new_str, size, fmt, ap);
+ n = vsnprintf (*str, size, fmt, ap);
va_end(ap);
/* If that worked, return the size. */
if (n > -1 && n < size)
size = n+1; /* precisely what is needed */
else /* glibc 2.0 */
size *= 2; /* twice the old size */
- new_str = realloc(new_str, size);
- if (new_str == NULL) {
- free(new_str);
- *str = NULL;
- return -1;
- }
- *str = new_str;
+ *str = xrealloc(*str, size);
}
return -1; /* Just to be correct - it probably won't get here */
str_list_t *str_list_alloc()
{
- str_list_t *list = (str_list_t *)calloc(1, sizeof(str_list_t));
- if (list)
- str_list_init(list);
+ str_list_t *list = xcalloc(1, sizeof(str_list_t));
+ str_list_init(list);
return list;
}
#include <errno.h>
#include "void_list.h"
+#include "libbb/libbb.h"
int void_list_elt_init(void_list_elt_t *elt, void *data)
{
void_list_elt_t * void_list_elt_new (void *data) {
void_list_elt_t *elt;
/* freed in void_list_elt_deinit */
- elt = calloc(1, sizeof(void_list_elt_t));
- if (elt == NULL) {
- fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
- return NULL;
- }
+ elt = xcalloc(1, sizeof(void_list_elt_t));
void_list_elt_init(elt, data);
return elt;
}
#include "includes.h"
#include "xregex.h"
+#include "libbb/libbb.h"
static void print_regcomp_err(const regex_t *preg, int err);
fprintf(stderr, "%s: Error compiling regex:", __FUNCTION__);
size = regerror(err, preg, 0, 0);
- error = calloc(1, size);
- if (error) {
- regerror(err, preg, error, size);
- fprintf(stderr, "%s\n", error);
- }
+ error = xcalloc(1, size);
+ regerror(err, preg, error, size);
+ fprintf(stderr, "%s\n", error);
free(error);
}