+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
#include <sys/types.h>
#include <limits.h>
#include <fcntl.h>
#include <expat.h>
#include "pool.h"
+#include "util.h"
#include "repo_rpmmd.h"
l += strlen(r) + 1;
if (l > pd->acontent)
{
- pd->content = realloc(pd->content, l + 256);
+ pd->content = xrealloc(pd->content, l + 256);
pd->acontent = l + 256;
}
c = pd->content;
int l = strlen(k) + 1 + strlen(n) + 1;
if (l > pd->acontent)
{
- pd->content = realloc(pd->content, l + 256);
+ pd->content = xrealloc(pd->content, l + 256);
pd->acontent = l + 256;
}
sprintf(pd->content, "%s:%s", k, n);
#if 0
fprintf(stderr, "numpacks: %d\n", pd->numpacks);
#endif
- pool->solvables = realloc(pool->solvables, (pool->nsolvables + pd->numpacks) * sizeof(Solvable));
- pd->start = pool->solvables + pd->repo->start;
+ pool->solvables = xrealloc2(pool->solvables, (pool->nsolvables + pd->numpacks), sizeof(Solvable));
+ pd->start = pool->solvables + pool->nsolvables;
memset(pd->start, 0, pd->numpacks * sizeof(Solvable));
}
}
l = pd->lcontent + len + 1;
if (l > pd->acontent)
{
- pd->content = realloc(pd->content, l + 256);
+ pd->content = xrealloc(pd->content, l + 256);
pd->acontent = l + 256;
}
c = pd->content + pd->lcontent;
#define BUFF_SIZE 8192
-Repo *
-pool_addrepo_rpmmd(Pool *pool, FILE *fp)
+void
+repo_add_rpmmd(Repo *repo, FILE *fp)
{
+ Pool *pool = repo->pool;
struct parsedata pd;
char buf[BUFF_SIZE];
int i, l;
- Repo *repo;
struct stateswitch *sw;
- repo = pool_addrepo_empty(pool);
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start)
+ repo->start = pool->nsolvables;
+
memset(&pd, 0, sizeof(pd));
for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
{
XML_ParserFree(parser);
pool->nsolvables += pd.pack;
- repo->nsolvables = pd.pack;
+ repo->nsolvables += pd.pack;
free(pd.content);
- return repo;
}