- rename pool_addfileprovides_ids to pool_addfileprovides_queue, make it fill a queue
authorMichael Schroeder <mls@suse.de>
Wed, 1 Feb 2012 15:52:35 +0000 (16:52 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 1 Feb 2012 15:52:35 +0000 (16:52 +0100)
bindings/solv.i
examples/p5solv
examples/pysolv
examples/rbsolv
examples/solv.c
src/libsolv.ver
src/pool.c
src/pool.h
tools/common_write.c

index ba926fa..a1d9d5b 100644 (file)
@@ -946,15 +946,10 @@ typedef struct {
   void addfileprovides() {
     pool_addfileprovides($self);
   }
-  Queue addfileprovides_ids() {
+  Queue addfileprovides_queue() {
     Queue r;
-    Id *addedfileprovides = 0;
     queue_init(&r);
-    pool_addfileprovides_ids($self, $self->installed, &addedfileprovides);
-    if (addedfileprovides) {
-      for (; *addedfileprovides; addedfileprovides++)
-        queue_push(&r, *addedfileprovides);
-    }
+    pool_addfileprovides_queue($self, &r);
     return r;
   }
   void createwhatprovides() {
index fd9915a..f864997 100755 (executable)
@@ -694,7 +694,7 @@ if ($cmd eq 'search') {
   exit(0);
 }
 
-my @addedprovides =  $pool->addfileprovides_ids();
+my @addedprovides = $pool->addfileprovides_queue();
 $pool->createwhatprovides();
 
 my @jobs;
index 5c7954a..8dea8ea 100755 (executable)
@@ -778,7 +778,7 @@ if cmd == 'list' or cmd == 'info' or cmd == 'install':
     if cmdlinerepo:
         cmdlinerepo.handle.internalize()
 
-addedprovides = pool.addfileprovides_ids()
+addedprovides = pool.addfileprovides_queue()
 if addedprovides:
     sysrepo.updateaddedprovides(addedprovides)
     for repo in repos:
index 00e8f05..52853cf 100755 (executable)
@@ -687,7 +687,7 @@ if cmd == 'search'
   exit
 end
 
-addedprovides = pool.addfileprovides_ids()
+addedprovides = pool.addfileprovides_queue()
 if !addedprovides.empty?
   sysrepo.updateaddedprovides(addedprovides)
   for repo in repos
index 09a9221..9c87f8a 100644 (file)
@@ -2481,20 +2481,19 @@ addsoftlocks(Pool *pool, Queue *job)
 
 
 void
-rewrite_repos(Pool *pool, Id *addedfileprovides)
+rewrite_repos(Pool *pool, Queue *addedfileprovides)
 {
   Repo *repo;
   Repodata *data;
   Map providedids;
   Queue fileprovidesq;
-  Id id;
-  int i, j, n, nprovidedids;
+  int i, j, n;
   struct repoinfo *cinfo;
 
   map_init(&providedids, pool->ss.nstrings);
   queue_init(&fileprovidesq);
-  for (nprovidedids = 0; (id = addedfileprovides[nprovidedids]) != 0; nprovidedids++)
-    MAPSET(&providedids, id);
+  for (i = 0; i < addedfileprovides->count; i++)
+    MAPSET(&providedids, addedfileprovides->elements[i]);
   FOR_REPOS(i, repo)
     {
       /* make sure this repo has just one main repodata */
@@ -2510,12 +2509,10 @@ rewrite_repos(Pool *pool, Id *addedfileprovides)
          for (j = 0; j < fileprovidesq.count; j++)
            if (MAPTST(&providedids, fileprovidesq.elements[j]))
              n++;
-         if (n == nprovidedids)
+         if (n == addedfileprovides->count)
            continue;   /* nothing new added */
        }
-      /* oh my! */
-      for (j = 0; addedfileprovides[j]; j++)
-       repodata_add_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides[j]);
+      repodata_set_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides);
       repodata_internalize(data);
       writecachedrepo(repo, data, 0, cinfo ? cinfo->cookie : installedcookie);
     }
@@ -2622,7 +2619,7 @@ main(int argc, char **argv)
   char inbuf[128], *ip;
   int allpkgs = 0;
   FILE **newpkgsfps;
-  Id *addedfileprovides = 0;
+  Queue addedfileprovides;
   Id repofilter = 0;
   int cleandeps = 0;
 
@@ -2836,11 +2833,11 @@ main(int argc, char **argv)
 
   // FOR_REPOS(i, repo)
   //   printf("%s: %d solvables\n", repo->name, repo->nsolvables);
-  addedfileprovides = 0;
-  pool_addfileprovides_ids(pool, pool->installed, &addedfileprovides);
-  if (addedfileprovides && *addedfileprovides)
-    rewrite_repos(pool, addedfileprovides);
-  solv_free(addedfileprovides);
+  queue_init(&addedfileprovides);
+  pool_addfileprovides_queue(pool, &addedfileprovides);
+  if (addedfileprovides.count)
+    rewrite_repos(pool, &addedfileprovides);
+  queue_free(&addedfileprovides);
   pool_createwhatprovides(pool);
 
   queue_init(&job);
index 57c6507..4da45b2 100644 (file)
@@ -38,7 +38,7 @@ SOLV_1.0 {
                policy_is_illegal;
                pool_add_fileconflicts_deps;
                pool_addfileprovides;
-               pool_addfileprovides_ids;
+               pool_addfileprovides_queue;
                pool_addrelproviders;
                pool_alloctmpspace;
                pool_arch2color_slow;
index a337914..8724011 100644 (file)
@@ -1086,21 +1086,24 @@ pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, stru
 }
 
 void
-pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp)
+pool_addfileprovides_queue(Pool *pool, Queue *idq)
 {
   Solvable *s;
-  Repo *repo;
+  Repo *installed, *repo;
   struct searchfiles sf, isf, *isfp;
   struct addfileprovides_cbdata cbd;
   int i;
   unsigned int now;
 
+  installed = pool->installed;
   now = solv_timems(0);
   memset(&sf, 0, sizeof(sf));
   map_init(&sf.seen, pool->ss.nstrings + pool->nrels);
   memset(&isf, 0, sizeof(isf));
   map_init(&isf.seen, pool->ss.nstrings + pool->nrels);
 
+  if (idq)
+    queue_empty(idq);
   isfp = installed ? &isf : 0;
   for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++)
     {
@@ -1126,8 +1129,6 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp)
   map_free(&isf.seen);
   POOL_DEBUG(SOLV_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles);
   cbd.dids = 0;
-  if (idp)
-    *idp = 0;
   if (sf.nfiles)
     {
 #if 0
@@ -1135,13 +1136,9 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp)
        POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in filelist\n", pool_id2str(pool, sf.ids[i]));
 #endif
       pool_addfileprovides_search(pool, &cbd, &sf, 0);
-      if (idp)
-       {
-         sf.ids = solv_extend(sf.ids, sf.nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
-         sf.ids[sf.nfiles] = 0;
-         *idp = sf.ids;
-         sf.ids = 0;
-       }
+      if (idq)
+        for (i = 0; i < sf.nfiles; i++)
+         queue_push(idq, sf.ids[i]);
       solv_free(sf.ids);
       for (i = 0; i < sf.nfiles; i++)
        {
@@ -1176,7 +1173,7 @@ pool_addfileprovides_ids(Pool *pool, Repo *installed, Id **idp)
 void
 pool_addfileprovides(Pool *pool)
 {
-  pool_addfileprovides_ids(pool, pool->installed, 0);
+  pool_addfileprovides_queue(pool, 0);
 }
 
 void
index 8b9997a..4c1245d 100644 (file)
@@ -250,7 +250,7 @@ static inline int pool_match_nevr(Pool *pool, Solvable *s, Id d)
  */
 extern void pool_createwhatprovides(Pool *pool);
 extern void pool_addfileprovides(Pool *pool);
-extern void pool_addfileprovides_ids(Pool *pool, struct _Repo *installed, Id **idp);
+extern void pool_addfileprovides_queue(Pool *pool, Queue *idq);
 extern void pool_freewhatprovides(Pool *pool);
 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
 
index ba45e6f..608ae96 100644 (file)
@@ -200,20 +200,20 @@ tool_write(Repo *repo, const char *basename, const char *attrname)
   char **languages = 0;
   int nlanguages = 0;
   int i, j, k, l;
-  Id *addedfileprovides = 0;
   struct keyfilter_data kd;
+  Queue addedfileprovides;
 
   memset(&kd, 0, sizeof(kd));
   info = repo_add_repodata(repo, 0);
   repodata_set_str(info, SOLVID_META, REPOSITORY_TOOLVERSION, LIBSOLV_TOOLVERSION);
-  pool_addfileprovides_ids(repo->pool, 0, &addedfileprovides);
-  if (addedfileprovides && *addedfileprovides)
+  queue_init(&addedfileprovides);
+  pool_addfileprovides_queue(repo->pool, &addedfileprovides);
+  if (addedfileprovides.count)
     {
       kd.haveaddedfileprovides = 1;
-      for (i = 0; addedfileprovides[i]; i++)
-        repodata_add_idarray(info, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides[i]);
+      repodata_set_idarray(info, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &addedfileprovides);
     }
-  solv_free(addedfileprovides);
+  queue_free(&addedfileprovides);
 
   pool_freeidhashes(repo->pool);       /* free some mem */