Relax memory requirements on 64bit platforms; fix two memleaks.

This commit is contained in:
Juan RP 2013-06-12 10:04:10 +02:00
parent 6a9e394a60
commit db1efb3aa6
33 changed files with 83 additions and 74 deletions

View File

@ -37,8 +37,8 @@ struct xferstat {
/* from transaction.c */
int install_new_pkg(struct xbps_handle *, const char *, bool);
int update_pkg(struct xbps_handle *, const char *);
int dist_upgrade(struct xbps_handle *, size_t, bool, bool);
int exec_transaction(struct xbps_handle *, size_t, bool, bool);
int dist_upgrade(struct xbps_handle *, int, bool, bool);
int exec_transaction(struct xbps_handle *, int, bool, bool);
/* from question.c */
bool yesno(const char *, ...);
@ -51,7 +51,7 @@ void fetch_file_progress_cb(struct xbps_fetch_cb_data *, void *);
void state_cb(struct xbps_state_cb_data *, void *);
/* From util.c */
void print_package_line(const char *, size_t, bool);
size_t get_maxcols(void);
void print_package_line(const char *, int, bool);
int get_maxcols(void);
#endif /* !_XBPS_INSTALL_DEFS_H_ */

View File

@ -102,7 +102,7 @@ main(int argc, char **argv)
const char *rootdir, *cachedir, *conffile, *defrepo;
int i, c, flags, rv, fflag = 0;
bool sync, yes, reinstall, drun, update;
size_t maxcols;
int maxcols;
rootdir = cachedir = conffile = defrepo = NULL;
flags = rv = 0;

View File

@ -48,7 +48,7 @@ struct transaction {
static void
show_missing_deps(prop_array_t a)
{
size_t i;
unsigned int i;
const char *str;
fprintf(stderr, "Unable to locate some required packages:\n");
@ -61,7 +61,7 @@ show_missing_deps(prop_array_t a)
static void
show_conflicts(prop_array_t a)
{
size_t i;
unsigned int i;
const char *str;
fprintf(stderr, "Conflicting packages were found:\n");
@ -93,7 +93,7 @@ show_actions(prop_object_iterator_t iter)
}
static void
show_package_list(prop_object_iterator_t iter, const char *match, size_t cols)
show_package_list(prop_object_iterator_t iter, const char *match, int cols)
{
prop_object_t obj;
const char *pkgver, *tract;
@ -110,7 +110,7 @@ show_package_list(prop_object_iterator_t iter, const char *match, size_t cols)
}
static int
show_transaction_sizes(struct transaction *trans, size_t cols)
show_transaction_sizes(struct transaction *trans, int cols)
{
uint64_t dlsize = 0, instsize = 0, rmsize = 0;
char size[8];
@ -186,7 +186,7 @@ show_transaction_sizes(struct transaction *trans, size_t cols)
}
int
dist_upgrade(struct xbps_handle *xhp, size_t cols, bool yes, bool drun)
dist_upgrade(struct xbps_handle *xhp, int cols, bool yes, bool drun)
{
int rv = 0;
@ -256,7 +256,7 @@ update_pkg(struct xbps_handle *xhp, const char *pkgname)
}
int
exec_transaction(struct xbps_handle *xhp, size_t maxcols, bool yes, bool drun)
exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
{
prop_array_t mdeps, cflicts;
struct transaction *trans;

View File

@ -35,7 +35,7 @@
#include <xbps_api.h>
#include "defs.h"
size_t
int
get_maxcols(void)
{
struct winsize ws;
@ -47,9 +47,9 @@ get_maxcols(void)
}
void
print_package_line(const char *str, size_t maxcols, bool reset)
print_package_line(const char *str, int maxcols, bool reset)
{
static size_t cols;
static int cols;
static bool first;
if (reset) {

View File

@ -49,7 +49,7 @@ check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, void *arg)
{
prop_dictionary_t pkg_propsd = arg;
prop_array_t array;
size_t i;
unsigned int i;
const char *reqpkg;
bool test_broken = false;

View File

@ -77,7 +77,7 @@ check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, void *arg)
prop_array_t array;
prop_object_t obj;
prop_dictionary_t filesd = arg;
size_t i;
unsigned int i;
const char *file, *tgt = NULL;
char *path, *p, *buf, *buf2, *lnk, *dname, *tgt_path;
int rv;

View File

@ -46,7 +46,7 @@ pkgdb_format_021(struct xbps_handle *xhp, const char *plist_new)
{
prop_array_t array, rdeps;
prop_dictionary_t pkgdb, pkgd;
size_t i;
unsigned int i;
char *pkgname, *plist;
plist = xbps_xasprintf("%s/pkgdb.plist", xhp->metadir);

View File

@ -55,8 +55,8 @@ int ownedby(struct xbps_handle *, int, char **);
int repo_ownedby(struct xbps_handle *, int, char **);
/* From list.c */
size_t get_maxcols(void);
size_t find_longest_pkgver(struct xbps_handle *, prop_object_t);
int get_maxcols(void);
unsigned int find_longest_pkgver(struct xbps_handle *, prop_object_t);
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, prop_object_t, void *, bool *);

View File

@ -34,11 +34,11 @@
#include "defs.h"
struct list_pkgver_cb {
size_t pkgver_len;
size_t maxcols;
int pkgver_len;
int maxcols;
};
size_t
int
get_maxcols(void)
{
struct winsize ws;
@ -58,7 +58,7 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
struct list_pkgver_cb *lpc = arg;
const char *pkgver, *short_desc, *state_str;
char tmp[255], *out = NULL;
size_t i, len = 0;
int i, len = 0;
pkg_state_t state;
(void)xhp;
@ -167,8 +167,8 @@ repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done)
(void)arg;
(void)done;
printf("%s (%zu packages)\n", repo->uri,
(size_t)prop_dictionary_count(repo->idx));
printf("%s (%u packages)\n", repo->uri,
prop_dictionary_count(repo->idx));
return 0;
}
@ -189,7 +189,7 @@ repo_list(struct xbps_handle *xhp)
struct fflongest {
prop_dictionary_t d;
size_t len;
unsigned int len;
};
static int
@ -201,7 +201,7 @@ _find_longest_pkgver_cb(struct xbps_handle *xhp,
struct fflongest *ffl = arg;
prop_dictionary_t pkgd;
const char *pkgver;
size_t len;
unsigned int len;
(void)xhp;
(void)loop_done;
@ -219,7 +219,7 @@ _find_longest_pkgver_cb(struct xbps_handle *xhp,
return 0;
}
size_t
unsigned int
find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o)
{
struct fflongest ffl;

View File

@ -128,7 +128,7 @@ repo_match_files_by_pattern(prop_array_t files,
struct ffdata *ffd)
{
const char *filestr;
size_t i;
unsigned int i;
int x;
for (i = 0; i < prop_array_count(files); i++) {

View File

@ -47,7 +47,7 @@
struct search_data {
int npatterns;
char **patterns;
size_t maxcols;
int maxcols;
prop_array_t results;
};
@ -56,7 +56,7 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
{
const char *pkgver, *desc, *inststr;
char tmp[256], *out;
size_t i, j, tlen = 0, len = 0;
unsigned int i, j, tlen = 0, len = 0;
/* Iterate over results array and find out largest pkgver string */
for (i = 0; i < prop_array_count(sd->results); i++) {
@ -80,7 +80,7 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
inststr = "[-]";
len = strlen(inststr) + strlen(tmp) + strlen(desc) + 3;
if (len > sd->maxcols) {
if ((int)len > sd->maxcols) {
out = malloc(sd->maxcols+1);
assert(out);
snprintf(out, sd->maxcols-3, "%s %s %s",
@ -103,7 +103,7 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
prop_dictionary_keysym_t ksym;
struct search_data *sd = arg;
const char *pkgver, *desc;
size_t i;
unsigned int i;
int x;
(void)done;
@ -120,7 +120,7 @@ search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
provides = prop_dictionary_get(pkgd, "provides");
for (x = 0; x < sd->npatterns; x++) {
size_t j;
unsigned int j;
bool vpkgfound = false;
for (j = 0; j < prop_array_count(provides); j++) {

View File

@ -40,7 +40,7 @@ print_rdeps(struct xbps_handle *xhp, prop_array_t rdeps,
prop_array_t currdeps;
prop_dictionary_t pkgd;
const char *pkgdep;
size_t i;
unsigned int i;
int j;
if (!origin)
@ -98,7 +98,7 @@ show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg)
{
prop_array_t reqby;
const char *pkgdep;
size_t i;
unsigned int i;
if ((reqby = xbps_pkgdb_get_pkg_revdeps(xhp, pkg)) != NULL) {
for (i = 0; i < prop_array_count(reqby); i++) {

View File

@ -43,7 +43,7 @@ print_value_obj(const char *keyname, prop_object_t obj,
prop_array_t allkeys;
prop_object_t obj2, keysym;
const char *ksymname, *value;
size_t i;
unsigned int i;
char size[8];
if (indent == NULL)
@ -151,7 +151,7 @@ static void
print_srcrevs(const char *keyname, prop_string_t obj)
{
const char *str = prop_string_cstring_nocopy(obj);
size_t i;
unsigned int i;
/* parse string appending a \t after EOL */
printf("%s:\n ", keyname);
@ -170,7 +170,7 @@ show_pkg_info(prop_dictionary_t dict)
prop_array_t all_keys;
prop_object_t obj, keysym;
const char *keyname;
size_t i;
unsigned int i;
all_keys = prop_dictionary_all_keys(dict);
for (i = 0; i < prop_array_count(all_keys); i++) {
@ -201,7 +201,7 @@ show_pkg_files(prop_dictionary_t filesd)
prop_object_t obj;
prop_dictionary_keysym_t ksym;
const char *keyname, *file;
size_t i, x;
unsigned int i, x;
if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY)
return EINVAL;

View File

@ -183,12 +183,12 @@ cachedir_clean(struct xbps_handle *xhp)
}
static int
remove_pkg(struct xbps_handle *xhp, const char *pkgname, size_t cols,
remove_pkg(struct xbps_handle *xhp, const char *pkgname, int cols,
bool recursive)
{
prop_array_t reqby;
const char *pkgver;
size_t x;
unsigned int x;
int rv;
rv = xbps_transaction_remove_pkg(xhp, pkgname, recursive);
@ -243,7 +243,7 @@ main(int argc, char **argv)
int i, c, flags, rv;
bool yes, drun, recursive, ignore_revdeps, clean_cache;
bool orphans, reqby_force;
size_t maxcols;
int maxcols;
rootdir = cachedir = conffile = NULL;
flags = rv = 0;

View File

@ -54,7 +54,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
const char *oldpkgver, *arch, *oldarch;
char *pkgver, *pkgname, *sha256, *repodir, *buf;
char *tmprepodir;
size_t x;
unsigned int x;
int i, rv, ret = 0;
bool flush = false, found = false;

View File

@ -143,7 +143,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
prop_dictionary_t idx, idxfiles;
const char *keyname;
char *pkgname;
size_t x, pkgcount, slicecount;
unsigned int x, pkgcount, slicecount;
int i, maxthreads, rv = 0;
bool flush = false;

View File

@ -138,7 +138,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
struct dirent *dp;
char *ext;
int i, maxthreads, rv = 0;
size_t slicecount, pkgcount;
unsigned int slicecount, pkgcount;
repo = xbps_repo_open(xhp, repodir);
if (repo == NULL) {

View File

@ -39,7 +39,7 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd,
{
prop_array_t array;
const char *cffile;
size_t i;
unsigned int i;
assert(prop_object_type(propsd) == PROP_TYPE_DICTIONARY);
assert(entry_pname != NULL);

View File

@ -37,7 +37,7 @@ merge_filelist(prop_dictionary_t d)
{
prop_array_t a, result;
prop_dictionary_t filed;
size_t i;
unsigned int i;
result = prop_array_create();
assert(result);
@ -78,7 +78,7 @@ xbps_find_pkg_obsoletes(struct xbps_handle *xhp,
prop_array_t instfiles, newfiles, obsoletes;
prop_object_t obj, obj2;
prop_string_t oldstr, newstr;
size_t i, x;
unsigned int i, x;
const char *oldhash;
char *file;
int rv = 0;

View File

@ -68,7 +68,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user)
prop_object_iterator_t iter;
const char *curpkgver, *deppkgver, *reqbydep;
bool automatic = false;
size_t i, x, j, cnt, reqbycnt;
unsigned int i, x, j, cnt, reqbycnt;
(void)orphans_user;

View File

@ -115,7 +115,10 @@ xbps_pkg_exec_script(struct xbps_handle *xhp,
bool update)
{
prop_data_t data;
void *buf;
size_t buflen;
const char *pkgver;
int rv;
assert(xhp);
assert(d);
@ -128,6 +131,10 @@ xbps_pkg_exec_script(struct xbps_handle *xhp,
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
return xbps_pkg_exec_buffer(xhp, prop_data_data(data),
prop_data_size(data), pkgver, action, update);
buf = prop_data_data(data);
buflen = prop_data_size(data);
rv = xbps_pkg_exec_buffer(xhp, buf, buflen, pkgver, action, update);
free(buf);
return rv;
}

View File

@ -166,6 +166,7 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
return EINVAL;
}
free(pkgname);
prop_object_release(pkgd);
} else {
if ((rv = set_new_state(pkgd, state)) != 0)
return rv;

View File

@ -57,7 +57,7 @@ find_pkg_symlink_target(prop_dictionary_t d, const char *file)
{
prop_array_t links;
prop_object_t obj;
size_t i;
unsigned int i;
const char *pkgfile, *tgt = NULL;
char *rfile;
@ -147,6 +147,7 @@ create_pkg_metaplist(struct xbps_handle *xhp, const char *pkgname, const char *p
pkgver, buf, strerror(errno));
}
free(buf);
prop_object_release(pkg_metad);
return rv;
}

View File

@ -143,7 +143,7 @@ xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
prop_array_t allkeys;
prop_object_t obj;
prop_dictionary_t pkgd;
size_t i;
unsigned int i;
int rv;
bool done = false;

View File

@ -110,7 +110,7 @@ xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
{
prop_object_t obj;
prop_array_t array;
size_t i;
unsigned int i;
int rv = 0;
bool cbloop_done = false;
@ -212,7 +212,7 @@ array_replace_dict(prop_array_t array,
bool bypattern)
{
prop_object_t obj;
size_t i;
unsigned int i;
const char *curpkgver;
char *curpkgname;

View File

@ -183,7 +183,7 @@ vpkg_user_conf(struct xbps_handle *xhp,
{
const char *vpkgver, *pkg = NULL;
char *vpkgname = NULL, *tmp;
size_t i, j, cnt;
unsigned int i, j, cnt;
if (xhp->cfg == NULL)
return NULL;

View File

@ -38,7 +38,7 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
prop_object_t obj;
const char *curname, *pkgdep;
char *curpkgname;
size_t idx = 0;
unsigned int idx = 0;
bool found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);

View File

@ -64,7 +64,7 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
prop_string_t reqpkg_str;
prop_object_iterator_t iter = NULL;
prop_object_t obj;
size_t idx = 0;
unsigned int idx = 0;
bool add_pkgdep, pkgfound, update_pkgdep;
int rv = 0;
@ -150,14 +150,14 @@ find_repo_deps(struct xbps_handle *xhp,
prop_array_t unsorted, /* array of unsorted deps */
prop_array_t pkg_rdeps_array, /* current pkg rundeps array */
const char *curpkg, /* current pkgver */
size_t *depth) /* max recursion depth */
unsigned short *depth) /* max recursion depth */
{
prop_dictionary_t curpkgd, tmpd;
prop_object_t obj;
prop_object_iterator_t iter;
prop_array_t curpkgrdeps;
pkg_state_t state;
size_t x;
unsigned int x;
const char *reqpkg, *pkgver_q, *reason = NULL;
char *pkgname, *reqpkgname;
int rv = 0;
@ -389,7 +389,7 @@ xbps_repository_find_deps(struct xbps_handle *xhp,
{
prop_array_t pkg_rdeps;
const char *pkgver;
size_t depth = 0;
unsigned short depth = 0;
pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends");
if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY)

View File

@ -119,7 +119,7 @@ int
xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
{
const char *repouri;
size_t i;
unsigned int i;
if (xhp->cfg == NULL)
return ENOTSUP;

View File

@ -193,7 +193,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
char *pkgname;
bool foundhold = false, newpkg_found = false;
int rv = 0;
size_t x;
unsigned int x;
if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv;
@ -273,7 +273,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp,
prop_array_t unsorted, orphans, orphans_pkg, reqby;
prop_object_t obj;
const char *pkgver;
size_t count;
unsigned int count;
int rv = 0;
assert(pkgname != NULL);
@ -351,7 +351,7 @@ xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
prop_array_t orphans, unsorted;
prop_object_t obj;
const char *pkgver;
size_t count;
unsigned int count;
int rv = 0;
orphans = xbps_find_pkg_orphans(xhp, NULL);

View File

@ -43,7 +43,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
const char *pattern, *pkgver, *curpkgver;
char *buf, *pkgname, *curpkgname;
bool instd_auto, sr;
size_t i;
unsigned int i;
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");

View File

@ -87,11 +87,11 @@ pkgdep_find(const char *pkg)
return NULL;
}
static ssize_t
static int32_t
pkgdep_find_idx(const char *pkg)
{
struct pkgdep *pd, *pd_new;
ssize_t idx = 0;
int32_t idx = 0;
const char *pkgver, *tract;
TAILQ_FOREACH_SAFE(pd, &pkgdep_list, pkgdep_entries, pd_new) {
@ -167,8 +167,8 @@ sort_pkg_rundeps(struct xbps_handle *xhp,
prop_dictionary_t curpkgd;
struct pkgdep *lpd, *pdn;
const char *str, *tract;
ssize_t pkgdepidx, curpkgidx;
size_t i, idx = 0;
int32_t pkgdepidx, curpkgidx;
uint32_t i, idx = 0;
int rv = 0;
xbps_dbg_printf_append(xhp, "\n");
@ -258,7 +258,7 @@ xbps_transaction_sort(struct xbps_handle *xhp)
prop_array_t provides, sorted, unsorted, rundeps;
prop_object_t obj;
struct pkgdep *pd;
size_t i, j, ndeps = 0, cnt = 0;
unsigned int i, j, ndeps = 0, cnt = 0;
const char *pkgname, *pkgver, *tract, *vpkgdep;
int rv = 0;
bool vpkg_found;

View File

@ -121,7 +121,7 @@ xbps_pkg_name(const char *pkg)
{
const char *p;
char *buf;
size_t len;
unsigned int len;
if ((p = strrchr(pkg, '-')) == NULL)
return NULL;
@ -143,7 +143,7 @@ char *
xbps_pkgpattern_name(const char *pkg)
{
char *res, *pkgname;
size_t len;
unsigned int len;
assert(pkg != NULL);