# HACK, remove if no longer needed!
bool write_first_repodata(FILE *fp) {
int oldnrepodata = $self->nrepodata;
- $self->nrepodata = 1;
+ $self->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata;
repo_write($self, fp, repo_write_stdkeyfilter, 0, 0);
$self->nrepodata = oldnrepodata;
return 1;
}
XRepodata *first_repodata() {
int i;
- if (!$self->nrepodata)
+ if ($self->nrepodata < 2)
return 0;
/* make sure all repodatas but the first are extensions */
- if ($self->repodata[0].loadcallback)
+ if ($self->repodata[1].loadcallback)
return 0;
- for (i = 1; i < $self->nrepodata; i++)
+ for (i = 2; i < $self->nrepodata; i++)
if (!$self->repodata[i].loadcallback)
return 0; /* oops, not an extension */
- return new_XRepodata($self, 0);
+ return new_XRepodata($self, 1);
}
bool __eq__(Repo *repo) {
else
{
int oldnrepodata = repo->nrepodata;
- repo->nrepodata = 1; /* XXX: do this right */
+ repo->nrepodata = oldnrepodata > 2 ? 2 : oldnrepodata; /* XXX: do this right */
repo_write(repo, fp, repo_write_stdkeyfilter, 0, 0);
repo->nrepodata = oldnrepodata;
onepiece = 0;
if (!repo->nrepodata)
continue;
cinfo = repo->appdata;
- data = repo->repodata + 0;
+ data = repo->repodata + 1;
if (data->store.pagefd == -1)
continue;
if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq))
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);
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;
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;
}
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;
}
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);
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 */
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;
}
{
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;
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
di->flags &= ~SEARCH_THISSOLVID;
di->nparents = 0;
di->rootlevel = 0;
- di->repodataid = 0;
+ di->repodataid = 1;
if (!di->pool->urepos)
{
di->state = di_bye;
/* 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);
/* 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;
/* 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 */
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];
}
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;
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;
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;