diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pool.c | 13 | ||||
-rw-r--r-- | src/pool.h | 8 | ||||
-rw-r--r-- | src/repo.c | 22 | ||||
-rw-r--r-- | src/repo.h | 2 | ||||
-rw-r--r-- | src/repodata.c | 16 |
5 files changed, 31 insertions, 30 deletions
@@ -53,6 +53,8 @@ pool_create(void) pool->solvables = solv_extend_resize(0, 2, sizeof(Solvable), SOLVABLE_BLOCK); pool->nsolvables = 2; memset(pool->solvables, 0, 2 * sizeof(Solvable)); + + /* initialize the system solvable */ s = pool->solvables + SYSTEMSOLVABLE; s->name = SYSTEM_SYSTEM; s->arch = ARCH_NOARCH; @@ -108,10 +110,11 @@ pool_freeallrepos(Pool *pool, int reuseids) int i; pool_freewhatprovides(pool); - for (i = 0; i < pool->nrepos; i++) + for (i = 1; i < pool->nrepos; i++) repo_freedata(pool->repos[i]); pool->repos = solv_free(pool->repos); pool->nrepos = 0; + pool->urepos = 0; /* the first two solvables don't belong to a repo */ pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids); } @@ -969,7 +972,7 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru Map donemap; int ndone, incomplete; - if (!pool->nrepos) + if (!pool->urepos) return; cbd->nfiles = sf->nfiles; @@ -979,14 +982,14 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru cbd->dids = solv_realloc2(cbd->dids, sf->nfiles, sizeof(Id)); map_init(&cbd->providedids, pool->ss.nstrings); - repoid = 0; - repo = repoonly ? repoonly : pool->repos[0]; + repoid = 1; + repo = repoonly ? repoonly : pool->repos[repoid]; map_init(&donemap, pool->nsolvables); queue_init(&fileprovidesq); provstart = provend = 0; for (;;) { - if (repo->disabled) + if (!repo || repo->disabled) { if (repoonly || ++repoid == pool->nrepos) break; @@ -70,6 +70,7 @@ struct _Pool { struct _Repo **repos; int nrepos; /* repos allocated */ + int urepos; /* repos in use */ struct _Repo *installed; /* packages considered installed */ @@ -323,10 +324,9 @@ void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts); for (vp = pool_whatprovides(pool, d) ; (v = pool->whatprovidesdata[vp++]) != 0; ) /* loop over all repositories */ -/* note that idx is not the repoid */ -#define FOR_REPOS(idx, r) \ - for (idx = 0; idx < pool->nrepos; idx++) \ - if ((r = pool->repos[idx]) != 0) +#define FOR_REPOS(repoid, r) \ + for (repoid = 1; repoid < pool->nrepos; repoid++) \ + if ((r = pool->repos[repoid]) != 0) #define POOL_DEBUG(type, ...) do {if ((pool->debugmask & (type)) != 0) pool_debug(pool, (type), __VA_ARGS__);} while (0) @@ -42,9 +42,12 @@ repo_create(Pool *pool, const char *name) pool_freewhatprovides(pool); repo = (Repo *)solv_calloc(1, sizeof(*repo)); + if (!pool->nrepos) + pool->nrepos = 1; /* start with repoid 1 */ pool->repos = (Repo **)solv_realloc2(pool->repos, pool->nrepos + 1, sizeof(Repo *)); - pool->repos[pool->nrepos++] = repo; - repo->repoid = pool->nrepos; + pool->repos[pool->nrepos] = repo; + pool->urepos++; + repo->repoid = pool->nrepos++; repo->name = name ? solv_strdup(name) : 0; repo->pool = pool; repo->start = pool->nsolvables; @@ -118,19 +121,16 @@ repo_free(Repo *repo, int reuseids) if (repo == pool->installed) pool->installed = 0; repo_empty(repo, reuseids); - for (i = 0; i < pool->nrepos; i++) /* find repo in pool */ + for (i = 1; i < pool->nrepos; i++) /* find repo in pool */ if (pool->repos[i] == repo) break; if (i == pool->nrepos) /* repo not in pool, return */ return; - if (i < pool->nrepos - 1) - { - memmove(pool->repos + i, pool->repos + i + 1, (pool->nrepos - 1 - i) * sizeof(Repo *)); - /* fix repo ids */ - for (; i < pool->nrepos - 1; i++) - pool->repos[i]->repoid = i + 1; - } - pool->nrepos--; + if (i == pool->nrepos - 1 && reuseids) + pool->nrepos--; + else + pool->repos[i] = 0; + pool->urepos--; repo_freedata(repo); } @@ -83,7 +83,7 @@ static inline const char *repo_name(const Repo *repo) static inline Repo *pool_id2repo(Pool *pool, Id repoid) { - return repoid ? pool->repos[repoid - 1] : 0; + return repoid < pool->nrepos ? pool->repos[repoid] : 0; } static inline int pool_installable(const Pool *pool, Solvable *s) diff --git a/src/repodata.c b/src/repodata.c index 802730d..c9dd25e 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -1181,7 +1181,7 @@ dataiterator_set_search(Dataiterator *di, Repo *repo, Id p) di->nparents = 0; di->rootlevel = 0; di->repodataid = 0; - if (!di->pool->nrepos) + if (!di->pool->urepos) { di->state = di_bye; return; @@ -1189,7 +1189,7 @@ dataiterator_set_search(Dataiterator *di, Repo *repo, Id p) if (!repo) { di->repoid = 1; - di->repo = di->pool->repos[0]; + di->repo = di->pool->repos[di->repoid]; } di->state = di_enterrepo; if (p) @@ -1277,9 +1277,7 @@ dataiterator_step(Dataiterator *di) switch (di->state) { case di_enterrepo: di_enterrepo: - if (!di->repo) - goto di_bye; - if (di->repo->disabled && !(di->flags & SEARCH_DISABLED_REPOS)) + if (!di->repo || (di->repo->disabled && !(di->flags & SEARCH_DISABLED_REPOS))) goto di_nextrepo; if (!(di->flags & SEARCH_THISSOLVID)) { @@ -1387,9 +1385,9 @@ dataiterator_step(Dataiterator *di) { di->repoid++; di->repodataid = 0; - if (di->repoid - 1 < di->pool->nrepos) + if (di->repoid < di->pool->nrepos) { - di->repo = di->pool->repos[di->repoid - 1]; + di->repo = di->pool->repos[di->repoid]; goto di_enterrepo; } } @@ -1691,13 +1689,13 @@ dataiterator_jump_to_solvid(Dataiterator *di, Id solvid) } else if (di->repoid > 0) { - if (!di->pool->nrepos) + if (!di->pool->urepos) { di->state = di_bye; return; } di->repoid = 1; - di->repo = di->pool->repos[0]; + di->repo = di->pool->repos[di->repoid]; } di->repodataid = 0; di->solvid = solvid; |