Mailinglist Archive: zypp-commit (268 mails)

< Previous Next >
[zypp-commit] r7796 - in /trunk/sat-solver: bindings/ examples/ruby/ src/ testsuite/ tools/
  • From: mlschroe@xxxxxxxxxxxxxxxx
  • Date: Tue, 13 Nov 2007 15:59:35 -0000
  • Message-id: <20071113155936.1BA2B3130F@xxxxxxxxxxxxxxxx>
Author: mlschroe
Date: Tue Nov 13 16:59:35 2007
New Revision: 7796

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7796&view=rev
Log:
- cleanup repo handlin API

Modified:
trunk/sat-solver/bindings/satsolver.i
trunk/sat-solver/examples/ruby/basic.rb
trunk/sat-solver/src/pool.c
trunk/sat-solver/src/repo.c
trunk/sat-solver/src/repo.h
trunk/sat-solver/src/repo_solv.c
trunk/sat-solver/src/repo_solv.h
trunk/sat-solver/testsuite/deptestomatic.c
trunk/sat-solver/testsuite/gimmick.c
trunk/sat-solver/testsuite/yps.c
trunk/sat-solver/tools/content2solv.c
trunk/sat-solver/tools/dumpsolv.c
trunk/sat-solver/tools/helix2solv.c
trunk/sat-solver/tools/mergesolv.c
trunk/sat-solver/tools/patchxml2solv.c
trunk/sat-solver/tools/repo_content.c
trunk/sat-solver/tools/repo_content.h
trunk/sat-solver/tools/repo_helix.c
trunk/sat-solver/tools/repo_helix.h
trunk/sat-solver/tools/repo_patchxml.c
trunk/sat-solver/tools/repo_patchxml.h
trunk/sat-solver/tools/repo_rpmdb.c
trunk/sat-solver/tools/repo_rpmdb.h
trunk/sat-solver/tools/repo_rpmmd.c
trunk/sat-solver/tools/repo_rpmmd.h
trunk/sat-solver/tools/repo_susetags.c
trunk/sat-solver/tools/repo_susetags.h
trunk/sat-solver/tools/repo_write.c
trunk/sat-solver/tools/repo_write.h
trunk/sat-solver/tools/rpmdb2solv.c
trunk/sat-solver/tools/rpmmd2solv.c
trunk/sat-solver/tools/susetags2solv.c

Modified: trunk/sat-solver/bindings/satsolver.i
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/bindings/satsolver.i (original)
+++ trunk/sat-solver/bindings/satsolver.i Tue Nov 13 16:59:35 2007
@@ -111,13 +111,10 @@
}


- Repo* add_empty_repo()
+ Repo* create_repo(const char *reponame)
{
- return pool_addrepo_empty($self);
+ return repo_create($self, reponame);
}
-
- Repo * add_repo_solv(FILE *fp, const char *reponame)
- { pool_addrepo_solv($self, fp, reponame); }
};
%newobject pool_create;
%delobject pool_free;
@@ -258,6 +255,7 @@
};

%include "repo.h"
+%include "repo_solv.h"

%nodefaultdtor Repo;
%extend Repo {
@@ -277,6 +275,11 @@
rb_yield(SWIG_NewPointerObj((void*) s, SWIGTYPE_p__Solvable, 0));
}
}
+
+ void add_solv(FILE *fp)
+ {
+ repo_add_solv($self, fp);
+ }
};

%include "repo_solv.h"

Modified: trunk/sat-solver/examples/ruby/basic.rb
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/examples/ruby/basic.rb?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/examples/ruby/basic.rb (original)
+++ trunk/sat-solver/examples/ruby/basic.rb Tue Nov 13 16:59:35 2007
@@ -8,10 +8,12 @@
#s = pool.add_empty_repo

f =
File.open('../../testsuite/data.libzypp/basic-exercises/exercise-20-packages.solv',
'r')
-s = pool.add_repo_solv(f, 'foo')
+s = pool.create_repo('foo');
+s.add_solv(f);

f =
File.open('../../testsuite/data.libzypp/basic-exercises/exercise-20-system.solv',
'r')
-installed = pool.add_repo_solv(f, 'system')
+installed = pool.create_repo('system');
+installed.add_solv(f);

pool.each_repo do |repo|
puts repo.name
@@ -54,4 +56,4 @@

solv.each_to_remove do |i|
puts "to remove #{i}"
-end
\ No newline at end of file
+end

Modified: trunk/sat-solver/src/pool.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.c (original)
+++ trunk/sat-solver/src/pool.c Tue Nov 13 16:59:35 2007
@@ -118,20 +118,12 @@
pool_free(Pool *pool)
{
int i;
- Repo *repo;

pool_freewhatprovides(pool);
pool_freeidhashes(pool);
- for (i = 0; i < pool->nrepos; i++)
- {
- repo = pool->repos[i];
- xfree(repo->idarraydata);
- xfree(repo->rpmdbid);
- xfree(repo);
- }
+ pool_freeallrepos(pool);
xfree(pool->id2arch);
xfree(pool->solvables);
- xfree(pool->repos);
xfree(pool->stringspace);
xfree(pool->strings);
xfree(pool->rels);

Modified: trunk/sat-solver/src/repo.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/src/repo.c (original)
+++ trunk/sat-solver/src/repo.c Tue Nov 13 16:59:35 2007
@@ -30,7 +30,7 @@
*/

Repo *
-pool_addrepo_empty(Pool *pool)
+repo_create(Pool *pool, const char *name)
{
Repo *repo;

@@ -38,13 +38,22 @@
repo = (Repo *)xcalloc(1, sizeof(*repo));
pool->repos = (Repo **)xrealloc(pool->repos, (pool->nrepos + 1) *
sizeof(Repo *));
pool->repos[pool->nrepos++] = repo;
- repo->name = "empty";
+ repo->name = name ? strdup(name) : 0;
repo->pool = pool;
repo->start = pool->nsolvables;
repo->nsolvables = 0;
return repo;
}

+static void
+repo_freedata(Repo *repo)
+{
+ xfree(repo->idarraydata);
+ xfree(repo->rpmdbid);
+ xfree((char *)repo->name);
+ xfree(repo);
+}
+
/*
* add Id to repo
* olddeps = old array to extend
@@ -242,8 +251,9 @@
*/

void
-pool_freerepo(Pool *pool, Repo *repo)
+repo_free(Repo *repo)
{
+ Pool *pool = repo->pool;
int i, nsolvables;

pool_freewhatprovides(pool);
@@ -273,10 +283,17 @@
pool->repos[i]->start -= nsolvables; /* adapt start offset of
remaining repos */
}
pool->nrepos = i;
+ repo_freedata(repo);
+}

- xfree(repo->idarraydata);
- xfree(repo->rpmdbid);
- xfree(repo);
+void
+pool_freeallrepos(Pool *pool)
+{
+ int i;
+ for (i = 0; i < pool->nrepos; i++)
+ repo_freedata(pool->repos[i]);
+ pool->repos = xfree(pool->repos);
+ pool->nrepos = 0;
}

Offset

Modified: trunk/sat-solver/src/repo.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/src/repo.h (original)
+++ trunk/sat-solver/src/repo.h Tue Nov 13 16:59:35 2007
@@ -30,13 +30,15 @@
Id *rpmdbid;
} Repo;

+extern Repo *repo_create(Pool *pool, const char *name);
+extern void repo_free(Repo *repo);
+
extern Offset repo_addid(Repo *repo, Offset olddeps, Id id);
extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq);
extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num);
extern Offset repo_fix_legacy(Repo *repo, Offset provides, Offset supplements);

-extern Repo *pool_addrepo_empty(Pool *pool);
-extern void pool_freerepo(Pool *pool, Repo *repo);
+extern void pool_freeallrepos(Pool *pool);

static inline const char *repo_name(const Repo *repo)
{

Modified: trunk/sat-solver/src/repo_solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/src/repo_solv.c (original)
+++ trunk/sat-solver/src/repo_solv.c Tue Nov 13 16:59:35 2007
@@ -174,9 +174,10 @@
* and add it to pool
*/

-Repo *
-pool_addrepo_solv(Pool *pool, FILE *fp, const char *reponame)
+void
+repo_add_solv(Repo *repo, FILE *fp)
{
+ Pool *pool = repo->pool;
int i, j, l;
unsigned int numid, numrel, numsolv, numsrcdata, numsolvdata;
int numsolvdatabits, type;
@@ -194,7 +195,6 @@
Reldep *ran;
SolvData *solvdata;
unsigned int size, size_str, size_idarray;
- Repo *repo;
Id *idarraydatap, *idarraydataend;
Offset ido;
unsigned int databits;
@@ -211,12 +211,8 @@
exit(1);
}

- /* create empty Repo */
- repo = pool_addrepo_empty(pool);
pool_freeidhashes(pool);

- repo->name = reponame;
-
numid = read_u32(fp);
numrel = read_u32(fp);
numsolv= read_u32(fp);
@@ -232,9 +228,10 @@
/*
* alloc buffers
*/
- /* alloc string buffer */
+
+ /* alloc string buffer */
strsp = (char *)xrealloc(pool->stringspace, pool->sstrings + sizeid + 1);
- /* alloc string offsets (Id -> Offset
into string space) */
+ /* alloc string offsets (Id -> Offset into string space) */
str = (Offset *)xrealloc(pool->strings, (pool->nstrings + numid) *
sizeof(Offset));

pool->stringspace = strsp;
@@ -243,7 +240,8 @@
/* point to _BEHIND_ already allocated string/Id space */
strsp += pool->sstrings;

- /* alloc id map for name and rel Ids */
+ /* alloc id map for name and rel Ids. this maps ids in the solv files
+ * to the ids in our pool */
idmap = (Id *)xcalloc(numid + numrel, sizeof(Id));

/*
@@ -412,7 +410,7 @@
}

/*
- * read (but dont store) repo data
+ * read (but dont store yet) repo data
*/

#if 0
@@ -485,30 +483,32 @@
fprintf(stderr, "too many data map bits\n");
exit(1);
}
+
+ /* make room for our idarrays */
if (size_idarray)
{
- size_idarray++; /* first entry is always zero */
- repo->idarraydata = (Id *)xmalloc(sizeof(Id) * size_idarray);
- repo->idarraysize = size_idarray;
- idarraydatap = repo->idarraydata;
- *idarraydatap++ = 0;
- idarraydataend = repo->idarraydata + size_idarray;
+ repo_reserve_ids(repo, 0, size_idarray);
+ idarraydatap = repo->idarraydata + repo->idarraysize;
+ repo->idarraysize += size_idarray;
+ idarraydataend = repo->idarraydata + repo->idarraysize;
+ repo->lastoff = 0;
}
else
{
- repo->idarraydata = 0;
- repo->idarraysize = 0;
idarraydatap = 0;
idarraydataend = 0;
}

- /* alloc solvables */
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start)
+ repo->start = pool->nsolvables;
+
+ /* alloc space for our solvables */
pool->solvables = (Solvable *)xrealloc(pool->solvables, (pool->nsolvables +
numsolv) * sizeof(Solvable));

if (numsolv) /* clear newly allocated area */
memset(pool->solvables + pool->nsolvables, 0, numsolv * sizeof(Solvable));
- repo->start = pool->nsolvables;
- repo->nsolvables = numsolv;

/*
* read solvables
@@ -517,7 +517,7 @@
#if 0
printf("read solvables\n");
#endif
- for (i = 0, s = pool->solvables + repo->start; i < numsolv; i++, s++)
+ for (i = 0, s = pool->solvables + repo->start + repo->nsolvables; i <
numsolv; i++, s++)
{
s->repo = repo;
databits = 0;
@@ -613,9 +613,8 @@
xfree(idmap);
xfree(solvdata);

+ repo->nsolvables += numsolv;
pool->nsolvables += numsolv;
-
- return repo;
}

// EOF

Modified: trunk/sat-solver/src/repo_solv.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_solv.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/src/repo_solv.h (original)
+++ trunk/sat-solver/src/repo_solv.h Tue Nov 13 16:59:35 2007
@@ -20,7 +20,7 @@
#include "pool.h"
#include "repo.h"

-extern Repo *pool_addrepo_solv(Pool *pool, FILE *fp, const char *name);
+extern void repo_add_solv(Repo *repo, FILE *fp);

#ifdef __cplusplus
}

Modified: trunk/sat-solver/testsuite/deptestomatic.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/deptestomatic.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/testsuite/deptestomatic.c (original)
+++ trunk/sat-solver/testsuite/deptestomatic.c Tue Nov 13 16:59:35 2007
@@ -567,7 +567,8 @@
perror( solvname );
return NULL;
}
- Repo *s = pool_addrepo_solv( pd->pool, fp, name );
+ Repo *s = repo_create(pd->pool, name);
+ repo_add_solv(s, fp);
fclose( fp );
return s;
}
@@ -653,8 +654,8 @@
pd->channels = (struct _channelmap *)realloc( pd->channels,
pd->nchannels * sizeof( struct _channelmap ) );
struct _channelmap *cmap = pd->channels + (pd->nchannels-1);

- cmap->repo = pd->locales = pool_addrepo_empty(pool);
- pd->locales->name = cmap->name = strdup( "locales" );
+ cmap->repo = pd->locales = repo_create(pool, "locales");
+ cmap->name = strdup( "locales" );
cmap->nid = str2id( pd->pool, cmap->name, 1 );
}

@@ -1192,7 +1193,7 @@
case STATE_TRIAL: { /* trial complete */

if (!pd->system)
- pd->system = pool_addrepo_empty( pd->pool );
+ pd->system = repo_create( pd->pool, 0 );

if (pd->arch)
pool_setarch( pd->pool, id2str(pd->pool, pd->arch) );
@@ -1384,7 +1385,7 @@
for ( i = 0; i < pd.nchannels; ++i )
{
free( pd.channels[i].name );
- pool_freerepo( pd.pool, pd.channels[i].repo );
+ repo_free( pd.channels[i].repo );
}

for ( i = 0; i < pd.nmodaliases; ++i )

Modified: trunk/sat-solver/testsuite/gimmick.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/gimmick.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/testsuite/gimmick.c (original)
+++ trunk/sat-solver/testsuite/gimmick.c Tue Nov 13 16:59:35 2007
@@ -28,12 +28,14 @@
int main(int argc, char **argv)
{
Pool *pool;
+ Repo *repo;
Id id;
Solvable *s;
Id p, *pp;

pool = pool_create();
- pool_addrepo_solv(pool, stdin, "");
+ repo = repo_create(pool, "<stdin>");
+ repo_add_solv(repo, stdin);
if (argc == 2)
id = str2id(pool, argv[1], 1);
else

Modified: trunk/sat-solver/testsuite/yps.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/yps.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/testsuite/yps.c (original)
+++ trunk/sat-solver/testsuite/yps.c Tue Nov 13 16:59:35 2007
@@ -141,7 +141,8 @@
perror(argv[1]);
exit(1);
}
- system = pool_addrepo_solv(pool, fp, "system");
+ system = repo_create(pool, "system");
+ repo_add_solv(system, fp);
channel = 0;
fclose(fp);

@@ -156,7 +157,8 @@
perror(argv[1]);
exit(1);
}
- channel = pool_addrepo_solv(pool, fp, argv[1]);
+ channel = repo_create(pool, argv[1]);
+ repo_add_solv(channel, fp);
fclose(fp);
argv++;
argc--;

Modified: trunk/sat-solver/tools/content2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/content2solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/content2solv.c (original)
+++ trunk/sat-solver/tools/content2solv.c Tue Nov 13 16:59:35 2007
@@ -20,8 +20,9 @@
main(int argc, char **argv)
{
Pool *pool = pool_create();
- Repo *repo = pool_addrepo_content(pool, stdin);
- pool_writerepo(pool, repo, stdout);
+ Repo *repo = repo_create(pool, "<stdin>");
+ repo_add_content(repo, stdin);
+ repo_write(repo, stdout);
pool_free(pool);
return 0;
}

Modified: trunk/sat-solver/tools/dumpsolv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/dumpsolv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/dumpsolv.c (original)
+++ trunk/sat-solver/tools/dumpsolv.c Tue Nov 13 16:59:35 2007
@@ -42,7 +42,8 @@
}
}
pool = pool_create();
- repo = pool_addrepo_solv(pool, stdin, "");
+ repo = repo_create(pool, argc != 1 ? argv[1] : "<stdin>");
+ repo_add_solv(repo, stdin);
printf("repo contains %d solvables\n", repo->nsolvables);
for (i = repo->start; i < repo->start + repo->nsolvables; i++)
{

Modified: trunk/sat-solver/tools/helix2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/helix2solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/helix2solv.c (original)
+++ trunk/sat-solver/tools/helix2solv.c Tue Nov 13 16:59:35 2007
@@ -29,8 +29,9 @@
main(int argc, char **argv)
{
Pool *pool = pool_create();
- Repo *repo = pool_addrepo_helix(pool, stdin);
- pool_writerepo(pool, repo, stdout);
+ Repo *repo = repo_create(pool, "<stdin>");
+ repo_add_helix(repo, stdin);
+ repo_write(repo, stdout);
pool_free(pool);
exit(0);
}

Modified: trunk/sat-solver/tools/mergesolv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/mergesolv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/mergesolv.c (original)
+++ trunk/sat-solver/tools/mergesolv.c Tue Nov 13 16:59:35 2007
@@ -39,7 +39,7 @@
perror(argv[1]);
exit(0);
}
- pool_addrepo_solv(pool, fp, "");
+ repo_add_solv(repo_create(pool, ""), fp);
fclose(fp);
}
if (!pool->nrepos)
@@ -90,13 +90,13 @@
}
while (pool->nrepos > 1)
{
- pool_freerepo (pool, pool->repos[1]);
+ repo_free(pool->repos[1]);
}
free (pool->repos[0]->idarraydata);
pool->repos[0]->idarraydata = new_id;
pool->repos[0]->idarraysize = new_id_size;

- pool_writerepo(pool, pool->repos[0], stdout);
+ repo_write(pool->repos[0], stdout);
pool_free(pool);

return 0;

Modified: trunk/sat-solver/tools/patchxml2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/patchxml2solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/patchxml2solv.c (original)
+++ trunk/sat-solver/tools/patchxml2solv.c Tue Nov 13 16:59:35 2007
@@ -20,8 +20,9 @@
main(int argc, char **argv)
{
Pool *pool = pool_create();
- Repo *repo = pool_addrepo_patchxml(pool, stdin);
- pool_writerepo(pool, repo, stdout);
+ Repo *repo = repo_create(pool, "<stdin>");
+ repo_add_patchxml(repo, stdin);
+ repo_write(repo, stdout);
pool_free(pool);
exit(0);
}

Modified: trunk/sat-solver/tools/repo_content.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_content.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_content.c (original)
+++ trunk/sat-solver/tools/repo_content.c Tue Nov 13 16:59:35 2007
@@ -160,17 +160,16 @@
return olddeps;
}

-Repo *
-pool_addrepo_content(Pool *pool, FILE *fp)
+void
+repo_add_content(Repo *repo, FILE *fp)
{
+ Pool *pool = repo->pool;
char *line, *linep;
int aline;
- Repo *repo;
Solvable *s;
int pack;
struct parsedata pd;

- repo = pool_addrepo_empty(pool);
memset(&pd, 0, sizeof(pd));
line = xmalloc(1024);
aline = 1024;
@@ -223,9 +222,9 @@
if ((pack & PACK_BLOCK) == 0)
{
pool->solvables = realloc(pool->solvables, (pool->nsolvables
+ pack + PACK_BLOCK + 1) * sizeof(Solvable));
- memset(pool->solvables + repo->start + pack, 0, (PACK_BLOCK +
1) * sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables + pack, 0,
(PACK_BLOCK + 1) * sizeof(Solvable));
}
- s = pool->solvables + repo->start + pack;
+ s = pool->solvables + pool->nsolvables + pack;
s->repo = repo;
s->name = str2id(pool, join(&pd, pd.kind, ":", value), 1);
pack++;
@@ -276,10 +275,8 @@
s->supplements = repo_fix_legacy(repo, s->provides, s->supplements);

pool->nsolvables += pack;
- repo->nsolvables = pack;
+ repo->nsolvables += pack;
if (pd.tmp)
free(pd.tmp);
free(line);
-
- return repo;
}

Modified: trunk/sat-solver/tools/repo_content.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_content.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_content.h (original)
+++ trunk/sat-solver/tools/repo_content.h Tue Nov 13 16:59:35 2007
@@ -5,4 +5,4 @@
* for further information
*/

-Repo * pool_addrepo_content(Pool *pool, FILE *fp);
+void repo_add_content(Repo *repo, FILE *fp);

Modified: trunk/sat-solver/tools/repo_helix.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_helix.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_helix.c (original)
+++ trunk/sat-solver/tools/repo_helix.c Tue Nov 13 16:59:35 2007
@@ -443,7 +443,7 @@
if ((pd->pack & PACK_BLOCK) == 0) /* alloc new block ? */
{
pool->solvables = (Solvable *)realloc(pool->solvables,
(pool->nsolvables + pd->pack + PACK_BLOCK + 1) * sizeof(Solvable));
- pd->start = pool->solvables + pd->repo->start;
+ pd->start = pool->solvables + pool->nsolvables;
memset(pd->start + pd->pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable));
}

@@ -817,19 +817,21 @@
*
*/

-Repo *
-pool_addrepo_helix(Pool *pool, FILE *fp)
+void
+repo_add_helix(Repo *repo, FILE *fp)
{
+ Pool *pool = repo->pool;
Parsedata pd;
char buf[BUFF_SIZE];
int i, l;
- Repo *repo;
struct stateswitch *sw;

- // create empty repo
- repo = pool_addrepo_empty(pool);
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start)
+ repo->start = pool->nsolvables;

- // prepare parsedata
+ /* prepare parsedata */
memset(&pd, 0, sizeof(pd));
for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
{
@@ -872,10 +874,8 @@

// adapt package count
pool->nsolvables += pd.pack;
- repo->nsolvables = pd.pack;
+ repo->nsolvables += pd.pack;

free(pd.content);
free(pd.evrspace);
-
- return repo;
}

Modified: trunk/sat-solver/tools/repo_helix.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_helix.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_helix.h (original)
+++ trunk/sat-solver/tools/repo_helix.h Tue Nov 13 16:59:35 2007
@@ -17,6 +17,6 @@
#include "pool.h"
#include "repo.h"

-extern Repo *pool_addrepo_helix(Pool *pool, FILE *fp);
+extern void repo_add_helix(Repo *repo, FILE *fp);

#endif /* REPO_HELIX_H */

Modified: trunk/sat-solver/tools/repo_patchxml.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_patchxml.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_patchxml.c (original)
+++ trunk/sat-solver/tools/repo_patchxml.c Tue Nov 13 16:59:35 2007
@@ -303,7 +303,7 @@
if ((pd->pack & PACK_BLOCK) == 0)
{
pool->solvables = realloc(pool->solvables, (pool->nsolvables +
pd->pack + PACK_BLOCK + 1) * sizeof(Solvable));
- pd->start = pool->solvables + pd->repo->start;
+ pd->start = pool->solvables + pool->nsolvables;
memset(pd->start + pd->pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable));
}
#if 0
@@ -443,16 +443,20 @@

#define BUFF_SIZE 8192

-Repo *
-pool_addrepo_patchxml(Pool *pool, FILE *fp)
+void
+repo_add_patchxml(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++)
{
@@ -483,8 +487,7 @@
XML_ParserFree(parser);

pool->nsolvables += pd.pack;
- repo->nsolvables = pd.pack;
+ repo->nsolvables += pd.pack;

free(pd.content);
- return repo;
}

Modified: trunk/sat-solver/tools/repo_patchxml.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_patchxml.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_patchxml.h (original)
+++ trunk/sat-solver/tools/repo_patchxml.h Tue Nov 13 16:59:35 2007
@@ -5,4 +5,4 @@
* for further information
*/

-extern Repo *pool_addrepo_patchxml(Pool *pool, FILE *fp);
+extern void repo_add_patchxml(Repo *repo, FILE *fp);

Modified: trunk/sat-solver/tools/repo_rpmdb.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmdb.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_rpmdb.c (original)
+++ trunk/sat-solver/tools/repo_rpmdb.c Tue Nov 13 16:59:35 2007
@@ -509,9 +509,10 @@
*
*/

-Repo *
-pool_addrepo_rpmdb(Pool *pool, Repo *ref)
+void
+repo_add_rpmdb(Repo *repo, Repo *ref)
{
+ Pool *pool = repo->pool;
unsigned char buf[16];
DB *db = 0;
DBC *dbc = 0;
@@ -523,13 +524,15 @@
int i;
int rpmheadsize;
RpmHead *rpmhead;
- Repo *repo;
Solvable *s;
Id id, *refhash;
unsigned int refmask, h;
int asolv;

- repo = pool_addrepo_empty(pool);
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start)
+ repo->start = pool->nsolvables;

if (ref && !(ref->nsolvables && ref->rpmdbid))
ref = 0;
@@ -559,7 +562,7 @@
}
dbidp = (unsigned char *)&dbid;
pool->solvables = xrealloc(pool->solvables, (pool->nsolvables + 256) *
sizeof(Solvable));
- memset(pool->solvables + repo->start, 0, 256 * sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables, 0, 256 * sizeof(Solvable));
repo->rpmdbid = xcalloc(256, sizeof(unsigned int));
asolv = 256;
rpmheadsize = 0;
@@ -570,12 +573,12 @@
if (i >= asolv)
{
pool->solvables = xrealloc(pool->solvables, (pool->nsolvables +
asolv + 256) * sizeof(Solvable));
- memset(pool->solvables + repo->start + asolv, 0, 256 *
sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables + asolv, 0, 256 *
sizeof(Solvable));
repo->rpmdbid = xrealloc(repo->rpmdbid, (asolv + 256) *
sizeof(unsigned int));
memset(repo->rpmdbid + asolv, 0, 256 * sizeof(unsigned int));
asolv += 256;
}
- pool->solvables[repo->start + i].repo = repo;
+ pool->solvables[pool->nsolvables + i].repo = repo;
if (key.size != 4)
{
fprintf(stderr, "corrupt Packages database (key size)\n");
@@ -611,7 +614,7 @@
memcpy(rpmhead->data, (unsigned char *)data.data + 8, rpmhead->cnt *
16 + rpmhead->dcnt);
rpmhead->dp = rpmhead->data + rpmhead->cnt * 16;
repo->rpmdbid[i] = dbid;
- if (rpm2solv(pool, repo, pool->solvables + repo->start + i, rpmhead))
+ if (rpm2solv(pool, repo, pool->solvables + pool->nsolvables + i,
rpmhead))
i++;
}
nrpmids = i;
@@ -676,8 +679,8 @@
rpmheadsize = 0;
rpmhead = 0;

- pool->solvables = xrealloc(pool->solvables, (pool->nsolvables + nrpmids)
* sizeof(Solvable));
- memset(pool->solvables + repo->start, 0, nrpmids * sizeof(Solvable));
+ pool->solvables = xrealloc2(pool->solvables, (pool->nsolvables +
nrpmids), sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables, 0, nrpmids *
sizeof(Solvable));
repo->rpmdbid = calloc(nrpmids, sizeof(unsigned int));

refhash = 0;
@@ -694,7 +697,7 @@
refhash[h] = i + 1; /* make it non-zero */
}
}
- s = pool->solvables + repo->start;
+ s = pool->solvables + pool->nsolvables;
for (i = 0; i < nrpmids; i++, rp++, s++)
{
s->repo = repo;
@@ -812,9 +815,8 @@
if (rpmhead)
free(rpmhead);
pool->nsolvables += nrpmids;
- repo->nsolvables = nrpmids;
+ repo->nsolvables += nrpmids;

if (db)
db->close(db, 0);
- return repo;
}

Modified: trunk/sat-solver/tools/repo_rpmdb.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmdb.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_rpmdb.h (original)
+++ trunk/sat-solver/tools/repo_rpmdb.h Tue Nov 13 16:59:35 2007
@@ -5,4 +5,4 @@
* for further information
*/

-extern Repo *pool_addrepo_rpmdb(Pool *pool, Repo *ref);
+extern void repo_add_rpmdb(Repo *repo, Repo *ref);

Modified: trunk/sat-solver/tools/repo_rpmmd.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmmd.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_rpmmd.c (original)
+++ trunk/sat-solver/tools/repo_rpmmd.c Tue Nov 13 16:59:35 2007
@@ -14,6 +14,7 @@
#include <expat.h>

#include "pool.h"
+#include "util.h"
#include "repo_rpmmd.h"


@@ -138,7 +139,7 @@
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;
@@ -205,7 +206,7 @@
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);
@@ -272,8 +273,8 @@
#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));
}
}
@@ -410,7 +411,7 @@
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;
@@ -423,16 +424,20 @@

#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++)
{
@@ -463,8 +468,7 @@
XML_ParserFree(parser);

pool->nsolvables += pd.pack;
- repo->nsolvables = pd.pack;
+ repo->nsolvables += pd.pack;

free(pd.content);
- return repo;
}

Modified: trunk/sat-solver/tools/repo_rpmmd.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmmd.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_rpmmd.h (original)
+++ trunk/sat-solver/tools/repo_rpmmd.h Tue Nov 13 16:59:35 2007
@@ -5,4 +5,4 @@
* for further information
*/

-extern Repo *pool_addrepo_rpmmd(Pool *pool, FILE *fp);
+extern void repo_add_rpmmd(Repo *repo, FILE *fp);

Modified: trunk/sat-solver/tools/repo_susetags.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_susetags.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_susetags.c (original)
+++ trunk/sat-solver/tools/repo_susetags.c Tue Nov 13 16:59:35 2007
@@ -136,12 +136,12 @@

Attrstore *attr;

-Repo *
-pool_addrepo_susetags(Pool *pool, FILE *fp, Id vendor, int with_attr)
+void
+repo_add_susetags(Repo *repo, FILE *fp, Id vendor, int with_attr)
{
+ Pool *pool = repo->pool;
char *line, *linep;
int aline;
- Repo *repo;
Solvable *s;
int intag = 0;
int cummulate = 0;
@@ -151,7 +151,11 @@
char *sp[5];
struct parsedata pd;

- repo = pool_addrepo_empty(pool);
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start)
+ repo->start = pool->nsolvables;
+
attr = new_store (pool);
memset(&pd, 0, sizeof(pd));
line = malloc(1024);
@@ -240,9 +244,9 @@
if ((pack & PACK_BLOCK) == 0)
{
pool->solvables = realloc(pool->solvables, (pool->nsolvables +
pack + PACK_BLOCK + 1) * sizeof(Solvable));
- memset(pool->solvables + repo->start + pack, 0, (PACK_BLOCK + 1)
* sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables + pack, 0, (PACK_BLOCK
+ 1) * sizeof(Solvable));
}
- s = pool->solvables + repo->start + pack;
+ s = pool->solvables + pool->nsolvables + pack;
s->repo = repo;
last_found_pack = pack;
pack++;
@@ -293,7 +297,7 @@
{
if (nn >= pack)
nn = 0;
- s = pool->solvables + repo->start + nn;
+ s = pool->solvables + pool->nsolvables + nn;
if (s->name == name && s->evr == evr && s->arch == arch)
break;
}
@@ -425,9 +429,8 @@
s->supplements = repo_fix_legacy(repo, s->provides, s->supplements);

pool->nsolvables += pack;
- repo->nsolvables = pack;
+ repo->nsolvables += pack;
if (pd.tmp)
free(pd.tmp);
free(line);
- return repo;
}

Modified: trunk/sat-solver/tools/repo_susetags.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_susetags.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_susetags.h (original)
+++ trunk/sat-solver/tools/repo_susetags.h Tue Nov 13 16:59:35 2007
@@ -5,4 +5,4 @@
* for further information
*/

-extern Repo *pool_addrepo_susetags(Pool *pool, FILE *fp, Id vendor, int
with_attr);
+extern void repo_add_susetags(Repo *repo, FILE *fp, Id vendor, int with_attr);

Modified: trunk/sat-solver/tools/repo_write.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_write.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_write.c (original)
+++ trunk/sat-solver/tools/repo_write.c Tue Nov 13 16:59:35 2007
@@ -189,8 +189,9 @@
*/

void
-pool_writerepo(Pool *pool, Repo *repo, FILE *fp)
+repo_write(Repo *repo, FILE *fp)
{
+ Pool *pool = repo->pool;
int i, numsolvdata;
Solvable *s, *sstart;
NeedId *needid;

Modified: trunk/sat-solver/tools/repo_write.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_write.h?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_write.h (original)
+++ trunk/sat-solver/tools/repo_write.h Tue Nov 13 16:59:35 2007
@@ -18,6 +18,6 @@
#include "pool.h"
#include "repo.h"

-extern void pool_writerepo(Pool *pool, Repo *repo, FILE *fp);
+extern void repo_write(Repo *repo, FILE *fp);

#endif

Modified: trunk/sat-solver/tools/rpmdb2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/rpmdb2solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/rpmdb2solv.c (original)
+++ trunk/sat-solver/tools/rpmdb2solv.c Tue Nov 13 16:59:35 2007
@@ -26,7 +26,7 @@
main(int argc, char **argv)
{
Pool *pool = pool_create();
- Repo *ref = NULL;
+ Repo *repo, *ref = 0;
FILE *fp;

if (argc != 1)
@@ -37,21 +37,23 @@
perror(argv[1]);
exit(0);
}
- ref = pool_addrepo_solv(refpool, fp, "rpmdb");
+ ref = repo_create(refpool, "ref");
+ repo_add_solv(ref, fp);
fclose(fp);
}

- Repo *repo = pool_addrepo_rpmdb(pool, ref);
+ repo = repo_create(pool, "installed");
+ repo_add_rpmdb(repo, ref);
if (ref)
{
if (ref->pool != pool)
pool_free(ref->pool);
else
- pool_freerepo(pool, ref);
- ref = NULL;
+ repo_free(ref);
+ ref = 0;
}

- pool_writerepo(pool, repo, stdout);
+ repo_write(repo, stdout);
pool_free(pool);

exit(0);

Modified: trunk/sat-solver/tools/rpmmd2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/rpmmd2solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/rpmmd2solv.c (original)
+++ trunk/sat-solver/tools/rpmmd2solv.c Tue Nov 13 16:59:35 2007
@@ -20,8 +20,9 @@
main(int argc, char **argv)
{
Pool *pool = pool_create();
- Repo *repo = pool_addrepo_rpmmd(pool, stdin);
- pool_writerepo(pool, repo, stdout);
+ Repo *repo = repo_create(pool, "<stdin>");
+ repo_add_rpmmd(repo, stdin);
+ repo_write(repo, stdout);
pool_free(pool);
exit(0);
}

Modified: trunk/sat-solver/tools/susetags2solv.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/susetags2solv.c?rev=7796&r1=7795&r2=7796&view=diff
==============================================================================
--- trunk/sat-solver/tools/susetags2solv.c (original)
+++ trunk/sat-solver/tools/susetags2solv.c Tue Nov 13 16:59:35 2007
@@ -38,8 +38,9 @@
argv++;
}
Pool *pool = pool_create();
- Repo *repo = pool_addrepo_susetags(pool, stdin, 0, with_attr);
- pool_writerepo(pool, repo, stdout);
+ Repo *repo = repo_create(pool, "<stdin>");
+ repo_add_susetags(repo, stdin, 0, with_attr);
+ repo_write(repo, stdout);
if (with_attr && attr)
{
FILE *fp = fopen ("test.attr", "w");

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages