X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fopkg_remove.c;h=ec7540b896cbd648c56a3e81ff2df3468ad97abd;hp=1eda4f6a17fae395968710e25f9b07e204f629b8;hb=480538737a8a9be074a1848f2e52cf2d1ff4709f;hpb=acd905996191df6ab59050bd179a5ed11e6f72a4 diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c index 1eda4f6..ec7540b 100644 --- a/libopkg/opkg_remove.c +++ b/libopkg/opkg_remove.c @@ -27,6 +27,7 @@ #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. @@ -54,12 +55,7 @@ int pkg_has_installed_dependents(opkg_conf_t *conf, abstract_pkg_t *parent_apkg, /* 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++) { @@ -181,12 +177,7 @@ static int remove_autoinstalled (opkg_conf_t *conf, pkg_t *pkg) 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] != ' ') { @@ -194,7 +185,7 @@ static int remove_autoinstalled (opkg_conf_t *conf, pkg_t *pkg) ++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