summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2011-12-22 16:45:05 +0100
committerMichael Schroeder <mls@suse.de>2011-12-22 16:45:05 +0100
commite8dbbef9e187f5c71f9e53c638b8ab5db8f9bea0 (patch)
tree21eda88a1e522add9f1cdd70487b14166c4f6c84 /src
parentbbadd9b603eda7da569fce14c433efb2e1324f10 (diff)
downloadlibsolv-e8dbbef9e187f5c71f9e53c638b8ab5db8f9bea0.tar.gz
libsolv-e8dbbef9e187f5c71f9e53c638b8ab5db8f9bea0.tar.bz2
libsolv-e8dbbef9e187f5c71f9e53c638b8ab5db8f9bea0.zip
- make repodata also start with id 1
Diffstat (limited to 'src')
-rw-r--r--src/repo.c10
-rw-r--r--src/repo.h2
-rw-r--r--src/repo_solv.c8
-rw-r--r--src/repodata.c37
4 files changed, 38 insertions, 19 deletions
diff --git a/src/repo.c b/src/repo.c
index 75f6f37..418ba7f 100644
--- a/src/repo.c
+++ b/src/repo.c
@@ -64,7 +64,7 @@ void
repo_freedata(Repo *repo)
{
int i;
- for (i = 0; i < repo->nrepodata; i++)
+ for (i = 1; i < repo->nrepodata; i++)
repodata_freedata(repo->repodata + i);
solv_free(repo->repodata);
solv_free(repo->idarraydata);
@@ -104,7 +104,7 @@ repo_empty(Repo *repo, int reuseids)
repo->idarraysize = 0;
repo->lastoff = 0;
repo->rpmdbid = solv_free(repo->rpmdbid);
- for (i = 0; i < repo->nrepodata; i++)
+ for (i = 1; i < repo->nrepodata; i++)
repodata_freedata(repo->repodata + i);
solv_free(repo->repodata);
repo->repodata = 0;
@@ -1287,7 +1287,7 @@ repo_add_repodata(Repo *repo, int flags)
int i;
if ((flags & REPO_USE_LOADING) != 0)
{
- for (i = repo->nrepodata - 1; i >= 0; i--)
+ for (i = repo->nrepodata - 1; i > 0; i--)
if (repo->repodata[i].state == REPODATA_LOADING)
{
Repodata *data = repo->repodata + i;
@@ -1301,7 +1301,7 @@ repo_add_repodata(Repo *repo, int flags)
}
if ((flags & REPO_REUSE_REPODATA) != 0)
{
- for (i = repo->nrepodata - 1; i >= 0; i--)
+ for (i = repo->nrepodata - 1; i > 0; i--)
if (repo->repodata[i].state != REPODATA_STUB)
return repo->repodata + i;
}
@@ -1312,7 +1312,7 @@ Repodata *
repo_last_repodata(Repo *repo)
{
int i;
- for (i = repo->nrepodata - 1; i >= 0; i--)
+ for (i = repo->nrepodata - 1; i > 0; i--)
if (repo->repodata[i].state != REPODATA_STUB)
return repo->repodata + i;
return repo_add_repodata(repo, 0);
diff --git a/src/repo.h b/src/repo.h
index e96751d..52bec4a 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -290,6 +290,6 @@ void repo_internalize(Repo *repo);
void repo_disable_paging(Repo *repo);
#define FOR_REPODATAS(repo, rdid, data) \
- for (rdid = 0, data = repo->repodata + rdid; rdid < repo->nrepodata; rdid++, data++)
+ for (rdid = 1, data = repo->repodata + rdid; rdid < repo->nrepodata; rdid++, data++)
#endif /* LIBSOLV_REPO_H */
diff --git a/src/repo_solv.c b/src/repo_solv.c
index 6c21584..cbc6c93 100644
--- a/src/repo_solv.c
+++ b/src/repo_solv.c
@@ -1295,7 +1295,13 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
else
{
/* make it available as new repodata */
- repo->repodata = solv_realloc2(repo->repodata, repo->nrepodata + 1, sizeof(data));
+ if (!repo->nrepodata)
+ {
+ repo->nrepodata = 1;
+ repo->repodata = solv_calloc(2, sizeof(data));
+ }
+ else
+ repo->repodata = solv_realloc2(repo->repodata, repo->nrepodata + 1, sizeof(data));
repo->repodata[repo->nrepodata++] = data;
}
diff --git a/src/repodata.c b/src/repodata.c
index c9dd25e..3753a26 100644
--- a/src/repodata.c
+++ b/src/repodata.c
@@ -97,8 +97,16 @@ repodata_create(Repo *repo, int localpool)
{
Repodata *data;
- repo->nrepodata++;
- repo->repodata = solv_realloc2(repo->repodata, repo->nrepodata, sizeof(*data));
+ if (!repo->nrepodata)
+ {
+ repo->nrepodata = 2; /* start with id 1 */
+ repo->repodata = solv_calloc(repo->nrepodata, sizeof(*data));
+ }
+ else
+ {
+ repo->nrepodata++;
+ repo->repodata = solv_realloc2(repo->repodata, repo->nrepodata, sizeof(*data));
+ }
data = repo->repodata + repo->nrepodata - 1;
repodata_initdata(data, repo, localpool);
return data;
@@ -113,6 +121,11 @@ repodata_free(Repodata *data)
if (i < repo->nrepodata - 1)
memmove(repo->repodata + i, repo->repodata + i + 1, (repo->nrepodata - 1 - i) * sizeof(Repodata));
repo->nrepodata--;
+ if (repo->nrepodata == 1)
+ {
+ repo->repodata = solv_free(repo->repodata);
+ repo->nrepodata = 0;
+ }
}
void
@@ -1180,7 +1193,7 @@ dataiterator_set_search(Dataiterator *di, Repo *repo, Id p)
di->flags &= ~SEARCH_THISSOLVID;
di->nparents = 0;
di->rootlevel = 0;
- di->repodataid = 0;
+ di->repodataid = 1;
if (!di->pool->urepos)
{
di->state = di_bye;
@@ -1287,9 +1300,9 @@ dataiterator_step(Dataiterator *di)
/* FALLTHROUGH */
case di_entersolvable: di_entersolvable:
- if (di->repodataid >= 0)
+ if (di->repodataid)
{
- di->repodataid = 0; /* reset repodata iterator */
+ di->repodataid = 1; /* reset repodata iterator */
if (di->solvid > 0 && !(di->flags & SEARCH_NO_STORAGE_SOLVABLE) && (!di->keyname || (di->keyname >= SOLVABLE_NAME && di->keyname <= RPM_RPMDBID)) && di->nparents - di->rootlevel == di->nkeynames)
{
di->key = solvablekeys + (di->keyname ? di->keyname - SOLVABLE_NAME : 0);
@@ -1300,13 +1313,13 @@ dataiterator_step(Dataiterator *di)
/* FALLTHROUGH */
case di_enterrepodata: di_enterrepodata:
- if (di->repodataid >= 0)
+ if (di->repodataid)
{
if (di->repodataid >= di->repo->nrepodata)
goto di_nextsolvable;
di->data = di->repo->repodata + di->repodataid;
}
- if (di->repodataid >= 0 && di->keyname == SOLVABLE_FILELIST && !dataiterator_filelistcheck(di))
+ if (di->repodataid && di->keyname == SOLVABLE_FILELIST && !dataiterator_filelistcheck(di))
goto di_nextrepodata;
if (!maybe_load_repodata(di->data, di->keyname))
goto di_nextrepodata;
@@ -1361,7 +1374,7 @@ dataiterator_step(Dataiterator *di)
/* FALLTHROUGH */
case di_nextrepodata: di_nextrepodata:
- if (di->repodataid >= 0 && ++di->repodataid < di->repo->nrepodata)
+ if (di->repodataid && ++di->repodataid < di->repo->nrepodata)
goto di_enterrepodata;
/* FALLTHROUGH */
@@ -1384,7 +1397,7 @@ dataiterator_step(Dataiterator *di)
if (di->repoid > 0)
{
di->repoid++;
- di->repodataid = 0;
+ di->repodataid = 1;
if (di->repoid < di->pool->nrepos)
{
di->repo = di->pool->repos[di->repoid];
@@ -1676,7 +1689,7 @@ dataiterator_jump_to_solvid(Dataiterator *di, Id solvid)
}
di->repoid = 0;
di->data = di->repo->repodata + di->pool->pos.repodataid;
- di->repodataid = -1;
+ di->repodataid = 0;
di->solvid = solvid;
di->state = di_enterrepo;
di->flags |= SEARCH_THISSOLVID;
@@ -1697,7 +1710,7 @@ dataiterator_jump_to_solvid(Dataiterator *di, Id solvid)
di->repoid = 1;
di->repo = di->pool->repos[di->repoid];
}
- di->repodataid = 0;
+ di->repodataid = 1;
di->solvid = solvid;
if (solvid)
di->flags |= SEARCH_THISSOLVID;
@@ -1712,7 +1725,7 @@ dataiterator_jump_to_repo(Dataiterator *di, Repo *repo)
di->rootlevel = 0;
di->repo = repo;
di->repoid = 0; /* 0 means stay at repo */
- di->repodataid = 0;
+ di->repodataid = 1;
di->solvid = 0;
di->flags &= ~SEARCH_THISSOLVID;
di->state = di_enterrepo;