From 1bb065df895aa08605a36a78396212a01b97bea8 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 1 Feb 2012 16:52:35 +0100 Subject: [PATCH] - rename pool_addfileprovides_ids to pool_addfileprovides_queue, make it fill a queue --- bindings/solv.i | 9 ++------- examples/p5solv | 2 +- examples/pysolv | 2 +- examples/rbsolv | 2 +- examples/solv.c | 27 ++++++++++++--------------- src/libsolv.ver | 2 +- src/pool.c | 21 +++++++++------------ src/pool.h | 2 +- tools/common_write.c | 12 ++++++------ 9 files changed, 34 insertions(+), 45 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index ba926fa..a1d9d5b 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -946,15 +946,10 @@ typedef struct { void addfileprovides() { pool_addfileprovides($self); } - Queue addfileprovides_ids() { + Queue addfileprovides_queue() { Queue r; - Id *addedfileprovides = 0; queue_init(&r); - pool_addfileprovides_ids($self, $self->installed, &addedfileprovides); - if (addedfileprovides) { - for (; *addedfileprovides; addedfileprovides++) - queue_push(&r, *addedfileprovides); - } + pool_addfileprovides_queue($self, &r); return r; } void createwhatprovides() { diff --git a/examples/p5solv b/examples/p5solv index fd9915a..f864997 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -694,7 +694,7 @@ if ($cmd eq 'search') { exit(0); } -my @addedprovides = $pool->addfileprovides_ids(); +my @addedprovides = $pool->addfileprovides_queue(); $pool->createwhatprovides(); my @jobs; diff --git a/examples/pysolv b/examples/pysolv index 5c7954a..8dea8ea 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -778,7 +778,7 @@ if cmd == 'list' or cmd == 'info' or cmd == 'install': if cmdlinerepo: cmdlinerepo.handle.internalize() -addedprovides = pool.addfileprovides_ids() +addedprovides = pool.addfileprovides_queue() if addedprovides: sysrepo.updateaddedprovides(addedprovides) for repo in repos: diff --git a/examples/rbsolv b/examples/rbsolv index 00e8f05..52853cf 100755 --- a/examples/rbsolv +++ b/examples/rbsolv @@ -687,7 +687,7 @@ if cmd == 'search' exit end -addedprovides = pool.addfileprovides_ids() +addedprovides = pool.addfileprovides_queue() if !addedprovides.empty? sysrepo.updateaddedprovides(addedprovides) for repo in repos diff --git a/examples/solv.c b/examples/solv.c index 09a9221..9c87f8a 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -2481,20 +2481,19 @@ addsoftlocks(Pool *pool, Queue *job) void -rewrite_repos(Pool *pool, Id *addedfileprovides) +rewrite_repos(Pool *pool, Queue *addedfileprovides) { Repo *repo; Repodata *data; Map providedids; Queue fileprovidesq; - Id id; - int i, j, n, nprovidedids; + int i, j, n; struct repoinfo *cinfo; map_init(&providedids, pool->ss.nstrings); queue_init(&fileprovidesq); - for (nprovidedids = 0; (id = addedfileprovides[nprovidedids]) != 0; nprovidedids++) - MAPSET(&providedids, id); + for (i = 0; i < addedfileprovides->count; i++) + MAPSET(&providedids, addedfileprovides->elements[i]); FOR_REPOS(i, repo) { /* make sure this repo has just one main repodata */ @@ -2510,12 +2509,10 @@ rewrite_repos(Pool *pool, Id *addedfileprovides) for (j = 0; j < fileprovidesq.count; j++) if (MAPTST(&providedids, fileprovidesq.elements[j])) n++; - if (n == nprovidedids) + if (n == addedfileprovides->count) continue; /* nothing new added */ } - /* oh my! */ - for (j = 0; addedfileprovides[j]; j++) - repodata_add_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides[j]); + repodata_set_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides); repodata_internalize(data); writecachedrepo(repo, data, 0, cinfo ? cinfo->cookie : installedcookie); } @@ -2622,7 +2619,7 @@ main(int argc, char **argv) char inbuf[128], *ip; int allpkgs = 0; FILE **newpkgsfps; - Id *addedfileprovides = 0; + Queue addedfileprovides; Id repofilter = 0; int cleandeps = 0; @@ -2836,11 +2833,11 @@ main(int argc, char **argv) // FOR_REPOS(i, repo) // printf("%s: %d solvables\n", repo->name, repo->nsolvables); - addedfileprovides = 0; - pool_addfileprovides_ids(pool, pool->installed, &addedfileprovides); - if (addedfileprovides && *addedfileprovides) - rewrite_repos(pool, addedfileprovides); - solv_free(addedfileprovides); + queue_init(&addedfileprovides); + pool_addfileprovides_queue(pool, &addedfileprovides); + if (addedfileprovides.count) + rewrite_repos(pool, &addedfileprovides); + queue_free(&addedfileprovides); pool_createwhatprovides(pool); queue_init(&job); diff --git a/src/libsolv.ver b/src/libsolv.ver index 57c6507..4da45b2 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -38,7 +38,7 @@ SOLV_1.0 { policy_is_illegal; pool_add_fileconflicts_deps; pool_addfileprovides; - pool_addfileprovides_ids; + pool_addfileprovides_queue; pool_addrelproviders; pool_alloctmpspace; pool_arch2color_slow; diff --git a/src/pool.c b/src/pool.c index a337914..8724011 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1086,21 +1086,24 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru } void -pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp) +pool_addfileprovides_queue(Pool *pool, Queue *idq) { Solvable *s; - Repo *repo; + Repo *installed, *repo; struct searchfiles sf, isf, *isfp; struct addfileprovides_cbdata cbd; int i; unsigned int now; + installed = pool->installed; now = solv_timems(0); memset(&sf, 0, sizeof(sf)); map_init(&sf.seen, pool->ss.nstrings + pool->nrels); memset(&isf, 0, sizeof(isf)); map_init(&isf.seen, pool->ss.nstrings + pool->nrels); + if (idq) + queue_empty(idq); isfp = installed ? &isf : 0; for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++) { @@ -1126,8 +1129,6 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp) map_free(&isf.seen); POOL_DEBUG(SOLV_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles); cbd.dids = 0; - if (idp) - *idp = 0; if (sf.nfiles) { #if 0 @@ -1135,13 +1136,9 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp) POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in filelist\n", pool_id2str(pool, sf.ids[i])); #endif pool_addfileprovides_search(pool, &cbd, &sf, 0); - if (idp) - { - sf.ids = solv_extend(sf.ids, sf.nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK); - sf.ids[sf.nfiles] = 0; - *idp = sf.ids; - sf.ids = 0; - } + if (idq) + for (i = 0; i < sf.nfiles; i++) + queue_push(idq, sf.ids[i]); solv_free(sf.ids); for (i = 0; i < sf.nfiles; i++) { @@ -1176,7 +1173,7 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp) void pool_addfileprovides(Pool *pool) { - pool_addfileprovides_ids(pool, pool->installed, 0); + pool_addfileprovides_queue(pool, 0); } void diff --git a/src/pool.h b/src/pool.h index 8b9997a..4c1245d 100644 --- a/src/pool.h +++ b/src/pool.h @@ -250,7 +250,7 @@ static inline int pool_match_nevr(Pool *pool, Solvable *s, Id d) */ extern void pool_createwhatprovides(Pool *pool); extern void pool_addfileprovides(Pool *pool); -extern void pool_addfileprovides_ids(Pool *pool, struct _Repo *installed, Id **idp); +extern void pool_addfileprovides_queue(Pool *pool, Queue *idq); extern void pool_freewhatprovides(Pool *pool); extern Id pool_queuetowhatprovides(Pool *pool, Queue *q); diff --git a/tools/common_write.c b/tools/common_write.c index ba45e6f..608ae96 100644 --- a/tools/common_write.c +++ b/tools/common_write.c @@ -200,20 +200,20 @@ tool_write(Repo *repo, const char *basename, const char *attrname) char **languages = 0; int nlanguages = 0; int i, j, k, l; - Id *addedfileprovides = 0; struct keyfilter_data kd; + Queue addedfileprovides; memset(&kd, 0, sizeof(kd)); info = repo_add_repodata(repo, 0); repodata_set_str(info, SOLVID_META, REPOSITORY_TOOLVERSION, LIBSOLV_TOOLVERSION); - pool_addfileprovides_ids(repo->pool, 0, &addedfileprovides); - if (addedfileprovides && *addedfileprovides) + queue_init(&addedfileprovides); + pool_addfileprovides_queue(repo->pool, &addedfileprovides); + if (addedfileprovides.count) { kd.haveaddedfileprovides = 1; - for (i = 0; addedfileprovides[i]; i++) - repodata_add_idarray(info, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides[i]); + repodata_set_idarray(info, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &addedfileprovides); } - solv_free(addedfileprovides); + queue_free(&addedfileprovides); pool_freeidhashes(repo->pool); /* free some mem */ -- 2.7.4