ref: refs/heads/master
commit b7c583929e3487a804a5b6b483f8b6a5f0ed31ae
Author: Michael Schroeder
Date: Mon Jun 15 19:24:20 2009 +0200
- add repoid to repo struct
---
src/pool.h | 1 +
src/repo.c | 8 +++++++-
src/repo.h | 8 +++++++-
src/rules.c | 4 ++--
4 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/pool.h b/src/pool.h
index 5dc813b..be0ef66 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -183,6 +183,7 @@ static inline Solvable *pool_id2solvable(Pool *pool, Id p)
{
return pool->solvables + p;
}
+
extern const char *solvable2str(Pool *pool, Solvable *s);
static inline const char *solvid2str(Pool *pool, Id p)
{
diff --git a/src/repo.c b/src/repo.c
index 4fc38b7..4a72485 100644
--- a/src/repo.c
+++ b/src/repo.c
@@ -46,6 +46,7 @@ repo_create(Pool *pool, const char *name)
repo = (Repo *)sat_calloc(1, sizeof(*repo));
pool->repos = (Repo **)sat_realloc2(pool->repos, pool->nrepos + 1, sizeof(Repo *));
pool->repos[pool->nrepos++] = repo;
+ repo->repoid = pool->nrepos;
repo->name = name ? strdup(name) : 0;
repo->pool = pool;
repo->start = pool->nsolvables;
@@ -298,7 +299,12 @@ repo_free(Repo *repo, int reuseids)
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 *));
+ {
+ 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--;
repo_freedata(repo);
}
diff --git a/src/repo.h b/src/repo.h
index 70ded77..6ceeb65 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -21,7 +21,8 @@
typedef struct _Repo {
const char *name;
- struct _Pool *pool; /* pool containing repo data */
+ Id repoid; /* our id */
+ Pool *pool; /* pool containing repo data */
int start; /* start of this repo solvables within pool->solvables */
int end; /* last solvable + 1 of this repo */
@@ -121,6 +122,11 @@ static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int
pool_free_solvable_block(repo->pool, start, count, reuseids);
}
+static inline Repo *pool_id2repo(Pool *pool, Id repoid)
+{
+ return pool->repos[repoid - 1];
+}
+
#define FOR_REPO_SOLVABLES(r, p, s) \
for (p = (r)->start, s = (r)->pool->solvables + p; p < (r)->end; p++, s = (r)->pool->solvables + p) \
if (s->repo == (r))
diff --git a/src/rules.c b/src/rules.c
index d13dd12..8d1ff8d 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -1149,9 +1149,9 @@ solver_createdupmaps(Solver *solv)
switch (how & SOLVER_JOBMASK)
{
case SOLVER_DISTUPGRADE:
- if (what < 0 || what > pool->nrepos)
+ if (what <= 0 || what > pool->nrepos)
break;
- repo = pool->repos[what];
+ repo = pool_id2repo(pool, what);
FOR_REPO_SOLVABLES(repo, p, s)
{
MAPSET(&solv->dupmap, p);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org