- switch dependencies from Id pointers to Offsets
authorMichael Schroeder <mls@suse.de>
Tue, 23 Oct 2007 15:24:36 +0000 (15:24 +0000)
committerMichael Schroeder <mls@suse.de>
Tue, 23 Oct 2007 15:24:36 +0000 (15:24 +0000)
12 files changed:
src/pool.c
src/solvable.h
src/solver.c
src/source_solv.c
tools/dumpsolv.c
tools/mergesolv.c
tools/source_helix.c
tools/source_patchxml.c
tools/source_rpmdb.c
tools/source_rpmmd.c
tools/source_susetags.c
tools/source_write.c

index 5f1d844..24362b7 100644 (file)
@@ -265,11 +265,11 @@ pool_prepare(Pool *pool)
     {
       Id *pp;
       s = pool->solvables + i;
-      pp = s->provides;
-      if (!pp)                 /* solvable does not provide anything */
+      if (!s->provides)
        continue;
       if (!pool_installable(pool, s))
        continue;
+      pp = s->source->idarraydata + s->provides;
       while ((id = *pp++) != ID_NULL)
        {
          if (ISRELDEP(id))
@@ -312,13 +312,13 @@ pool_prepare(Pool *pool)
     {
       Id *pp;
       s = pool->solvables + i;
-      pp = s->provides;
-      if (!pp)                        /* solvable does not provide anything */
+      if (!s->provides)
        continue;
       if (!pool_installable(pool, s))
        continue;
 
       /* for all provides of this solvable */
+      pp = s->source->idarraydata + s->provides;
       while ((id = *pp++) != 0)
        {
          if (ISRELDEP(id))
@@ -465,7 +465,8 @@ pool_addrelproviders(Pool *pool, Id d)
            printf("addrelproviders: checking package %s\n", id2str(pool, pool->p[p].name));
 #endif
          /* solvable p provides name in some rels */
-         for (pidp = pool->solvables[p].provides; (pid = *pidp++) != 0; )
+         pidp = pool->solvables[p].source->idarraydata + pool->solvables[p].provides;
+         while ((pid = *pidp++) != 0)
            {
              int pflags;
              Id pevr;
index 4840298..bc8cae6 100644 (file)
@@ -17,19 +17,19 @@ typedef struct _Solvable {
 
   Source *source;              /* source we belong to */
 
-  /* dependencies are pointers into idarray of source */
-  Id *provides;                        /* terminated with Id 0 */
-  Id *obsoletes;
-  Id *conflicts;
+  /* dependencies are offsets into idarray of source */
+  Offset provides;                     /* terminated with Id 0 */
+  Offset obsoletes;
+  Offset conflicts;
 
-  Id *requires;
-  Id *recommends;
-  Id *suggests;
+  Offset requires;
+  Offset recommends;
+  Offset suggests;
 
-  Id *supplements;
-  Id *enhances;
+  Offset supplements;
+  Offset enhances;
 
-  Id *freshens;
+  Offset freshens;
 } Solvable;
 
 #endif /* SOLVABLE_H */
index 507d41b..854f44e 100644 (file)
@@ -159,14 +159,20 @@ prune_to_recommended(Solver *solv, Queue *plist)
       if (p < 0)
        continue;
       s = pool->solvables + p;
-      if ((recp = s->recommends) != 0)
-        while ((rec = *recp++) != 0)
-         FOR_PROVIDES(p, pp, rec)
-           MAPSET(&solv->recommendsmap, p);
-      if ((sugp = s->suggests) != 0)
-        while ((sug = *sugp++) != 0)
-         FOR_PROVIDES(p, pp, sug)
-           MAPSET(&solv->suggestsmap, p);
+      if (s->recommends)
+       {
+         recp = s->source->idarraydata + s->recommends;
+          while ((rec = *recp++) != 0)
+           FOR_PROVIDES(p, pp, rec)
+             MAPSET(&solv->recommendsmap, p);
+       }
+      if (s->suggests)
+       {
+         sugp = s->source->idarraydata + s->suggests;
+          while ((sug = *sugp++) != 0)
+           FOR_PROVIDES(p, pp, sug)
+             MAPSET(&solv->suggestsmap, p);
+       }
     }
   /* prune to recommended/supplemented */
   for (i = j = 0; i < plist->count; i++)
@@ -180,16 +186,18 @@ prune_to_recommended(Solver *solv, Queue *plist)
       s = pool->solvables + p;
       if (!s->supplements && !s->freshens)
        continue;
-      if ((supp = s->supplements) != 0)
+      if (s->supplements)
        {
+         supp = s->source->idarraydata + s->supplements;
          while ((sup = *supp++) != 0)
            if (dep_fulfilled(solv, sup))
              break;
          if (!sup)
            continue;
        }
-      if ((supp = s->freshens) != 0)
+      if (s->freshens)
        {
+         supp = s->source->idarraydata + s->freshens;
          while ((sup = *supp++) != 0)
            if (dep_fulfilled(solv, sup))
              break;
@@ -213,8 +221,9 @@ prune_to_recommended(Solver *solv, Queue *plist)
          continue;
        }
       s = pool->solvables + p;
-      if (!(enhp = s->enhances))
+      if (!s->enhances)
        continue;
+      enhp = s->source->idarraydata + s->enhances;
       while ((enh = *enhp++) != 0)
        if (dep_fulfilled(solv, enh))
          break;
@@ -813,9 +822,10 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
        * check requires of s
        */
       
-      if ((reqp = s->requires) != ID_NULL)
+      if (s->requires)
        {
-         while ((req = *reqp++) != ID_NULL)
+         reqp = s->source->idarraydata + s->requires;
+         while ((req = *reqp++) != 0)
            {
              if (req == SOLVABLE_PREREQMARKER)   /* skip the marker */
                continue;
@@ -882,8 +892,9 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
        * check conflicts of s
        */
       
-      if ((conp = s->conflicts) != 0)
+      if (s->conflicts)
        {
+         conp = s->source->idarraydata + s->conflicts;
          while ((con = *conp++) != 0)
            {
              FOR_PROVIDES(p, pp, con)
@@ -902,8 +913,9 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
        */
       if (!system || n < system->start || n >= (system->start + system->nsolvables))
        {                              /* not installed */
-         if ((obsp = s->obsoletes) != 0)
+         if (s->obsoletes)
            {
+             obsp = s->source->idarraydata + s->obsoletes;
              while ((obs = *obsp++) != 0)
                {
                  FOR_PROVIDES(p, pp, obs)
@@ -920,13 +932,16 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
       /*-----------------------------------------
        * add recommends to the rule list
        */
-      if ((recp = s->recommends) != 0)
-       while ((rec = *recp++) != 0)
-         {
-           FOR_PROVIDES(p, pp, rec)
-             if (!MAPTST(m, p))
-               queuepush(&q, p);
-         }
+      if (s->recommends)
+       {
+         recp = s->source->idarraydata + s->recommends;
+         while ((rec = *recp++) != 0)
+           {
+             FOR_PROVIDES(p, pp, rec)
+               if (!MAPTST(m, p))
+                 queuepush(&q, p);
+           }
+       }
     }
   queuefree(&q);
 }
@@ -950,14 +965,20 @@ addrulesforsupplements(Solver *solv, Map *m)
       if (!pool_installable(pool, s))
        continue;
       sup = 0;
-      if ((supp = s->supplements) != 0)
-       while ((sup = *supp++) != ID_NULL)
-         if (dep_possible(solv, sup, m))
-           break;
-      if (!sup && (supp = s->freshens) != 0)
-       while ((sup = *supp++) != ID_NULL)
-         if (dep_possible(solv, sup, m))
-           break;
+      if (s->supplements)
+       {
+         supp = s->source->idarraydata + s->supplements;
+         while ((sup = *supp++) != ID_NULL)
+           if (dep_possible(solv, sup, m))
+             break;
+       }
+      if (!sup && s->freshens)
+       {
+         supp = s->source->idarraydata + s->freshens;
+         while ((sup = *supp++) != ID_NULL)
+           if (dep_possible(solv, sup, m))
+             break;
+       }
       if (!sup)
        continue;
       addrulesforsolvable(solv, s, m);
@@ -980,23 +1001,30 @@ addrulesforenhances(Solver *solv, Map *m)
       if (MAPTST(m, i))
        continue;
       s = pool->solvables + i;
-      if ((enhp = s->enhances) == 0)
+      if (!s->enhances)
        continue;
       if (!pool_installable(pool, s))
        continue;
+      enhp = s->source->idarraydata + s->enhances;
       while ((enh = *enhp++) != ID_NULL)
        if (dep_possible(solv, enh, m))
          break;
       if (!enh)
        continue;
-      if ((conp = s->conflicts) != 0)
-       while ((con = *conp++) != 0)
-         FOR_PROVIDES(p, pp, con)
-           addrule(solv, -i, -p);
-      if ((obsp = s->obsoletes) != 0)
-        while ((obs = *obsp++) != ID_NULL)
-         FOR_PROVIDES(p, pp, obs)
-           addrule(solv, -i, -p);
+      if (s->conflicts)
+       {
+         conp = s->source->idarraydata + s->conflicts;
+         while ((con = *conp++) != 0)
+           FOR_PROVIDES(p, pp, con)
+             addrule(solv, -i, -p);
+       }
+      if (s->obsoletes)
+       {
+         obsp = s->source->idarraydata + s->obsoletes;
+         while ((obs = *obsp++) != ID_NULL)
+           FOR_PROVIDES(p, pp, obs)
+             addrule(solv, -i, -p);
+       }
       FOR_PROVIDES(p, pp, s->name)
         if (s->name == pool->solvables[p].name)
          addrule(solv, -i, -p);
@@ -1029,6 +1057,7 @@ findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngr
   Pool *pool = solv->pool;
   Id p, *pp, n, p2, *pp2;
   Id obs, *obsp;
+  Solvable *ps;
 
   QUEUEEMPTY(qs);
   /*
@@ -1047,17 +1076,19 @@ findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngr
       if (p == n)              /* skip itself */
        continue;
 
-      if (s->name == pool->solvables[p].name)  /* name match */
+      ps = pool->solvables + p;
+      if (s->name == ps->name) /* name match */
        {
          if (!allowdowngrade                   /* consider downgrades ? */
-             && evrcmp(pool, s->evr, pool->solvables[p].evr) > 0)
+             && evrcmp(pool, s->evr, ps->evr) > 0)
            continue;
          /* XXX */
-         if (!allowarchchange && archchanges(pool, s, pool->solvables + p))
+         if (!allowarchchange && archchanges(pool, s, ps))
            continue;
        }
-      else if (!solv->noupdateprovide && (obsp = pool->solvables[p].obsoletes) != 0)   /* provides/obsoletes combination ? */
+      else if (!solv->noupdateprovide && ps->obsoletes)   /* provides/obsoletes combination ? */
        {
+         obsp = ps->source->idarraydata + ps->obsoletes;
          while ((obs = *obsp++) != 0)  /* for all obsoletes */
            {
              FOR_PROVIDES(p2, pp2, obs)   /* and all matching providers of the obsoletes */
@@ -2104,8 +2135,9 @@ run_solver(Solver *solv, int disablerules, int doweak)
                  s = pool->solvables + i;
                  /* installed, check for recommends */
                  /* XXX need to special case AND ? */
-                 if ((recp = s->recommends) != 0)
+                 if (s->recommends)
                    {
+                     recp = s->source->idarraydata + s->recommends;
                      while ((rec = *recp++) != 0)
                        {
                          qcount = dq.count;
@@ -2130,16 +2162,18 @@ run_solver(Solver *solv, int disablerules, int doweak)
                    continue;
                  if (!pool_installable(pool, s))
                    continue;
-                 if ((supp = s->supplements) != 0)
+                 if (s->supplements)
                    {
+                     supp = s->source->idarraydata + s->supplements;
                      while ((sup = *supp++) != 0)
                        if (dep_fulfilled(solv, sup))
                          break;
                      if (!sup)
                        continue;
                    }
-                 if ((supp = s->freshens) != 0)
+                 if (s->freshens)
                    {
+                     supp = s->source->idarraydata + s->freshens;
                      while ((sup = *supp++) != 0)
                        if (dep_fulfilled(solv, sup))
                          break;
@@ -2365,16 +2399,19 @@ printdecisions(Solver *solv)
       if (n >= solv->system->start && n < solv->system->start + solv->system->nsolvables)
        continue;
       s = pool->solvables + n;
-      if ((obsp = s->obsoletes) != 0)
-       while ((obs = *obsp++) != 0)
-         FOR_PROVIDES(p, pp, obs)
-           {
-             if (p >= solv->system->start && p < solv->system->start + solv->system->nsolvables)
-               {
-                 obsoletesmap[p] = n;
-                 obsoletesmap[n]++;
-               }
-           }
+      if (s->obsoletes)
+       {
+         obsp = s->source->idarraydata + s->obsoletes;
+         while ((obs = *obsp++) != 0)
+           FOR_PROVIDES(p, pp, obs)
+             {
+               if (p >= solv->system->start && p < solv->system->start + solv->system->nsolvables)
+                 {
+                   obsoletesmap[p] = n;
+                   obsoletesmap[n]++;
+                 }
+             }
+       }
       FOR_PROVIDES(p, pp, s->name)
        if (s->name == pool->solvables[p].name)
          {
@@ -2507,10 +2544,11 @@ create_obsolete_index(Solver *solv)
   for (i = 1; i < pool->nsolvables; i++)
     {
       s = pool->solvables + i;
-      if ((obsp = s->obsoletes) == 0)
+      if (!s->obsoletes)
        continue;
       if (!pool_installable(pool, s))
        continue;
+      obsp = s->source->idarraydata + s->obsoletes;
       while ((obs = *obsp++) != 0)
         FOR_PROVIDES(p, pp, obs)
          {
@@ -2533,10 +2571,11 @@ create_obsolete_index(Solver *solv)
   for (i = pool->nsolvables - 1; i > 0; i--)
     {
       s = pool->solvables + i;
-      if ((obsp = s->obsoletes) == 0)
+      if (!s->obsoletes)
        continue;
       if (!pool_installable(pool, s))
        continue;
+      obsp = s->source->idarraydata + s->obsoletes;
       while ((obs = *obsp++) != 0)
         FOR_PROVIDES(p, pp, obs)
          {
@@ -2836,17 +2875,20 @@ solve(Solver *solv, Queue *job)
          if (p < 0)
            continue;
          s = pool->solvables + p;
-         if ((sugp = s->suggests) != 0)
-           while ((sug = *sugp++) != 0)
-             {
-               FOR_PROVIDES(p, pp, sug)
-                 if (solv->decisionmap[p] > 0)
-                   break;
-               if (p)
-                 continue;     /* already fulfilled */
-               FOR_PROVIDES(p, pp, sug)
-                 MAPSET(&solv->suggestsmap, p);
-             }
+         if (s->suggests)
+           {
+             sugp = s->source->idarraydata + s->suggests;
+             while ((sug = *sugp++) != 0)
+               {
+                 FOR_PROVIDES(p, pp, sug)
+                   if (solv->decisionmap[p] > 0)
+                     break;
+                 if (p)
+                   continue;   /* already fulfilled */
+                 FOR_PROVIDES(p, pp, sug)
+                   MAPSET(&solv->suggestsmap, p);
+               }
+           }
        }
       for (i = 1; i < pool->nsolvables; i++)
        {
@@ -2855,10 +2897,11 @@ solve(Solver *solv, Queue *job)
          s = pool->solvables + i;
          if (!MAPTST(&solv->suggestsmap, i))
            {
-             if ((enhp = s->enhances) == 0)
+             if (!s->enhances)
                continue;
              if (!pool_installable(pool, s))
                continue;
+             enhp = s->source->idarraydata + s->enhances;
              while ((enh = *enhp++) != 0)
                if (dep_fulfilled(solv, enh))
                  break;
@@ -2866,8 +2909,9 @@ solve(Solver *solv, Queue *job)
                continue;
            }
          /* check if installation is possible at all */
-          if ((reqp = s->requires) != 0)
+          if (s->requires)
            {
+             reqp = s->source->idarraydata + s->requires;
              while ((req = *reqp++) != 0)
                {
                  if (req == SOLVABLE_PREREQMARKER)   /* skip the marker */
index 7e0edc7..d9a8311 100644 (file)
@@ -188,7 +188,8 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename)
   SolvData *solvdata;
   unsigned int size, size_str, size_idarray;
   Source *source;
-  Id *idarraydatap, *idarraydataend, *ida;
+  Id *idarraydatap, *idarraydataend;
+  Offset ido;
   unsigned int databits;
   Solvable *s;
 
@@ -478,10 +479,20 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename)
       exit(1);
     }
   if (size_idarray)
-    source->idarraydata = (Id *)xmalloc(sizeof(Id) * size_idarray);
-  source->idarraysize = size_idarray;
-  idarraydatap = source->idarraydata;
-  idarraydataend = source->idarraydata + size_idarray;
+    {
+      size_idarray++;  /* first entry is not used */
+      source->idarraydata = (Id *)xmalloc(sizeof(Id) * size_idarray);
+      source->idarraysize = size_idarray;
+      idarraydatap = source->idarraydata + 1;
+      idarraydataend = source->idarraydata + size_idarray;
+    }
+  else
+    {
+      source->idarraydata = 0;
+      source->idarraysize = 0;
+      idarraydatap = 0;
+      idarraydataend = 0;
+    }
 
   /* alloc solvables */
   pool->solvables = (Solvable *)xrealloc(pool->solvables, (pool->nsolvables + numsolv) * sizeof(Solvable));
@@ -559,42 +570,36 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename)
                    ;
                  break;
                }
-             ida = idarraydatap;
-             idarraydatap = read_idarray(fp, numid + numrel, idmap, ida, idarraydataend);
+             ido = idarraydatap - source->idarraydata;
+             idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend);
              if (id == SOLVABLE_PROVIDES)
-               s->provides = ida;
+               s->provides = ido;
              else if (id == SOLVABLE_OBSOLETES)
-               s->obsoletes = ida;
+               s->obsoletes = ido;
              else if (id == SOLVABLE_CONFLICTS)
-               s->conflicts = ida;
+               s->conflicts = ido;
              else if (id == SOLVABLE_REQUIRES)
-               s->requires = ida;
+               s->requires = ido;
              else if (id == SOLVABLE_RECOMMENDS)
-               s->recommends= ida;
+               s->recommends= ido;
              else if (id == SOLVABLE_SUPPLEMENTS)
-               s->supplements = ida;
+               s->supplements = ido;
              else if (id == SOLVABLE_SUGGESTS)
-               s->suggests = ida;
+               s->suggests = ido;
              else if (id == SOLVABLE_ENHANCES)
-               s->enhances = ida;
+               s->enhances = ido;
              else if (id == SOLVABLE_FRESHENS)
-               s->freshens = ida;
+               s->freshens = ido;
 #if 0
              printf("%s ->\n", id2str(pool, id));
-             for (; *ida; ida++)
-               printf("  %s\n", dep2str(pool, *ida));
+             for (; source->idarraydata[ido]; ido++)
+               printf("  %s\n", dep2str(pool, source->idarraydata[ido]));
 #endif
              break;
            }
        }
     }
 
-  if (idarraydatap > source->idarraydata + size_idarray)
-    {
-      fprintf(stderr, "idarray overflow\n");
-      exit(1);
-    }
-
   xfree(idmap);
   xfree(solvdata);
 
index cb7375a..8b4d37d 100644 (file)
@@ -7,12 +7,14 @@
 #include "source_solv.h"
 
 static void
-printids(Pool *pool, char *kind, Id *ids)
+printids(Source *source, char *kind, Offset ido)
 {
-  Id id;
-  if (!ids)
+  Pool *pool = source->pool;
+  Id id, *ids;
+  if (!ido)
     return;
   printf("%s:\n", kind);
+  ids = source->idarraydata + ido;
   while((id = *ids++) != 0)
     printf("  %s\n", dep2str(pool, id));
 }
@@ -41,15 +43,15 @@ int main(int argc, char **argv)
       printf("\n");
       printf("solvable %d:\n", i);
       printf("name: %s %s %s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch));
-      printids(pool, "provides", s->provides);
-      printids(pool, "obsoletes", s->obsoletes);
-      printids(pool, "conflicts", s->conflicts);
-      printids(pool, "requires", s->requires);
-      printids(pool, "recommends", s->recommends);
-      printids(pool, "suggests", s->suggests);
-      printids(pool, "supplements", s->supplements);
-      printids(pool, "enhances", s->enhances);
-      printids(pool, "freshens", s->freshens);
+      printids(source, "provides", s->provides);
+      printids(source, "obsoletes", s->obsoletes);
+      printids(source, "conflicts", s->conflicts);
+      printids(source, "requires", s->requires);
+      printids(source, "recommends", s->recommends);
+      printids(source, "suggests", s->suggests);
+      printids(source, "supplements", s->supplements);
+      printids(source, "enhances", s->enhances);
+      printids(source, "freshens", s->freshens);
     }
   exit(0);
 }
index f466b9b..932771e 100644 (file)
 #include "source_solv.h"
 #include "source_write.h"
 
-static void
-adjust (Id **val, Id * new_id, Source *source)
-{
-  if (!*val)
-    return;
-  assert (source->idarraydata <= *val);
-  assert (*val < source->idarraydata + source->idarraysize);
-  *val = new_id + (*val - source->idarraydata);
-}
-
 int
 main(int argc, char **argv)
 {
@@ -62,15 +52,24 @@ main(int argc, char **argv)
       for (si = source->start; si < source->start + source->nsolvables; si++)
         {
          Solvable *s = pool->solvables + si;
-         adjust (&s->provides, new_id + new_id_size, source);
-         adjust (&s->obsoletes, new_id + new_id_size, source);
-         adjust (&s->conflicts, new_id + new_id_size, source);
-         adjust (&s->requires, new_id + new_id_size, source);
-         adjust (&s->recommends, new_id + new_id_size, source);
-         adjust (&s->suggests, new_id + new_id_size, source);
-         adjust (&s->supplements, new_id + new_id_size, source);
-         adjust (&s->enhances, new_id + new_id_size, source);
-         adjust (&s->freshens, new_id + new_id_size, source);
+         if (s->provides)
+           s->provides += new_id_size;
+         if (s->obsoletes)
+           s->obsoletes += new_id_size;
+         if (s->conflicts)
+           s->conflicts += new_id_size;
+         if (s->requires)
+           s->requires += new_id_size;
+         if (s->recommends)
+           s->recommends += new_id_size;
+         if (s->suggests)
+           s->suggests+= new_id_size;
+         if (s->supplements)
+           s->supplements += new_id_size;
+         if (s->enhances)
+           s->enhances += new_id_size;
+         if (s->freshens)
+           s->freshens += new_id_size;
        }
       new_id_size += source->idarraysize;
       if (i > 0)
index 5b1bad1..7c2b753 100644 (file)
@@ -899,24 +899,15 @@ pool_addsource_helix(Pool *pool, FILE *fp)
   solvable = pool->solvables + source->start;
   for (i = 0; i < pd.pack; i++, solvable++)
     {
-      if (deps[i].provides)
-        solvable->provides = source->idarraydata + deps[i].provides;
-      if (deps[i].requires)
-        solvable->requires = source->idarraydata + deps[i].requires;
-      if (deps[i].conflicts)
-        solvable->conflicts = source->idarraydata + deps[i].conflicts;
-      if (deps[i].obsoletes)
-        solvable->obsoletes = source->idarraydata + deps[i].obsoletes;
-      if (deps[i].recommends)
-        solvable->recommends = source->idarraydata + deps[i].recommends;
-      if (deps[i].supplements)
-        solvable->supplements = source->idarraydata + deps[i].supplements;
-      if (deps[i].suggests)
-        solvable->suggests = source->idarraydata + deps[i].suggests;
-      if (deps[i].enhances)
-        solvable->enhances = source->idarraydata + deps[i].enhances;
-      if (deps[i].freshens)
-        solvable->freshens = source->idarraydata + deps[i].freshens;
+      solvable->provides = deps[i].provides;
+      solvable->requires = deps[i].requires;
+      solvable->conflicts = deps[i].conflicts;
+      solvable->obsoletes = deps[i].obsoletes;
+      solvable->recommends = deps[i].recommends;
+      solvable->supplements = deps[i].supplements;
+      solvable->suggests = deps[i].suggests;
+      solvable->enhances = deps[i].enhances;
+      solvable->freshens = deps[i].freshens;
     }
 
   free(deps);
index 38d3f69..773220c 100644 (file)
@@ -502,24 +502,15 @@ pool_addsource_patchxml(Pool *pool, FILE *fp)
   s = pool->solvables + source->start;
   for (i = 0; i < pd.pack; i++, s++)
     {
-      if (deps[i].provides)
-        s->provides = source->idarraydata + deps[i].provides;
-      if (deps[i].requires)
-        s->requires = source->idarraydata + deps[i].requires;
-      if (deps[i].conflicts)
-        s->conflicts = source->idarraydata + deps[i].conflicts;
-      if (deps[i].obsoletes)
-        s->obsoletes = source->idarraydata + deps[i].obsoletes;
-      if (deps[i].recommends)
-        s->recommends = source->idarraydata + deps[i].recommends;
-      if (deps[i].supplements)
-        s->supplements = source->idarraydata + deps[i].supplements;
-      if (deps[i].suggests)
-        s->suggests = source->idarraydata + deps[i].suggests;
-      if (deps[i].enhances)
-        s->enhances = source->idarraydata + deps[i].enhances;
-      if (deps[i].freshens)
-        s->freshens = source->idarraydata + deps[i].freshens;
+      s->provides = deps[i].provides;
+      s->requires = deps[i].requires;
+      s->conflicts = deps[i].conflicts;
+      s->obsoletes = deps[i].obsoletes;
+      s->recommends = deps[i].recommends;
+      s->supplements = deps[i].supplements;
+      s->suggests = deps[i].suggests;
+      s->enhances = deps[i].enhances;
+      s->freshens = deps[i].freshens;
     }
   free(deps);
   free(pd.content);
index b3f4d49..45e571d 100644 (file)
@@ -307,21 +307,23 @@ makedeps(Pool *pool, Source *source, RpmHead *rpmhead, int tagn, int tagv, int t
   return olddeps;
 }
 
-static unsigned int
-copydeps(Pool *pool, Source *source, Id *from, Pool *frompool)
+static Offset
+copydeps(Pool *pool, Source *source, Offset fromoff, Source *fromsource)
 {
   int cc;
-  Id id, *ida;
-  unsigned int olddeps;
+  Id id, *ida, *from;
+  Offset ido;
+  Pool *frompool = fromsource->pool;
 
-  if (!from)
+  if (!fromoff)
     return 0;
+  from = fromsource->idarraydata + fromoff;
   for (ida = from, cc = 0; *ida; ida++, cc++)
     ;
   if (cc == 0)
     return 0;
-  olddeps = source_reserve_ids(source, 0, cc);
-  ida = source->idarraydata + olddeps;
+  ido = source_reserve_ids(source, 0, cc);
+  ida = source->idarraydata + ido;
   if (frompool && pool != frompool)
     {
       while (*from)
@@ -343,7 +345,7 @@ copydeps(Pool *pool, Source *source, Id *from, Pool *frompool)
   else
     memcpy(ida, from, (cc + 1) * sizeof(Id));
   source->idarraysize += cc + 1;
-  return olddeps;
+  return ido;
 }
 
 
@@ -747,15 +749,15 @@ pool_addsource_rpmdb(Pool *pool, Source *ref)
                      if (r->arch)
                        s->arch = str2id(pool, id2str(ref->pool, r->arch), 1);
                    }
-                 deps[i].provides = copydeps(pool, source, r->provides, ref->pool);
-                 deps[i].requires = copydeps(pool, source, r->requires, ref->pool);
-                 deps[i].conflicts = copydeps(pool, source, r->conflicts, ref->pool);
-                 deps[i].obsoletes = copydeps(pool, source, r->obsoletes, ref->pool);
-                 deps[i].recommends = copydeps(pool, source, r->recommends, ref->pool);
-                 deps[i].suggests = copydeps(pool, source, r->suggests, ref->pool);
-                 deps[i].supplements = copydeps(pool, source, r->supplements, ref->pool);
-                 deps[i].enhances  = copydeps(pool, source, r->enhances, ref->pool);
-                 deps[i].freshens = copydeps(pool, source, r->freshens, ref->pool);
+                 deps[i].provides = copydeps(pool, source, r->provides, ref);
+                 deps[i].requires = copydeps(pool, source, r->requires, ref);
+                 deps[i].conflicts = copydeps(pool, source, r->conflicts, ref);
+                 deps[i].obsoletes = copydeps(pool, source, r->obsoletes, ref);
+                 deps[i].recommends = copydeps(pool, source, r->recommends, ref);
+                 deps[i].suggests = copydeps(pool, source, r->suggests, ref);
+                 deps[i].supplements = copydeps(pool, source, r->supplements, ref);
+                 deps[i].enhances  = copydeps(pool, source, r->enhances, ref);
+                 deps[i].freshens = copydeps(pool, source, r->freshens, ref);
                  continue;
                }
            }
@@ -837,24 +839,15 @@ pool_addsource_rpmdb(Pool *pool, Source *ref)
   s = pool->solvables + source->start;
   for (i = 0; i < nrpmids; i++, s++)
     {
-      if (deps[i].provides)
-       s->provides = source->idarraydata + deps[i].provides;
-      if (deps[i].requires)
-       s->requires = source->idarraydata + deps[i].requires;
-      if (deps[i].conflicts)
-       s->conflicts = source->idarraydata + deps[i].conflicts;
-      if (deps[i].obsoletes)
-       s->obsoletes = source->idarraydata + deps[i].obsoletes;
-      if (deps[i].recommends)
-       s->recommends = source->idarraydata + deps[i].recommends;
-      if (deps[i].supplements)
-       s->supplements = source->idarraydata + deps[i].supplements;
-      if (deps[i].suggests)
-       s->suggests = source->idarraydata + deps[i].suggests;
-      if (deps[i].enhances)
-       s->enhances = source->idarraydata + deps[i].enhances;
-      if (deps[i].freshens)
-       s->freshens = source->idarraydata + deps[i].freshens;
+      s->provides = deps[i].provides;
+      s->requires = deps[i].requires;
+      s->conflicts = deps[i].conflicts;
+      s->obsoletes = deps[i].obsoletes;
+      s->recommends = deps[i].recommends;
+      s->supplements = deps[i].supplements;
+      s->suggests = deps[i].suggests;
+      s->enhances = deps[i].enhances;
+      s->freshens = deps[i].freshens;
     }
   free(deps);
   if (db)
index d18e068..cc8a7d4 100644 (file)
@@ -473,24 +473,15 @@ pool_addsource_rpmmd(Pool *pool, FILE *fp)
   s = pool->solvables + source->start;
   for (i = 0; i < pd.pack; i++, s++)
     {
-      if (deps[i].provides)
-        s->provides = source->idarraydata + deps[i].provides;
-      if (deps[i].requires)
-        s->requires = source->idarraydata + deps[i].requires;
-      if (deps[i].conflicts)
-        s->conflicts = source->idarraydata + deps[i].conflicts;
-      if (deps[i].obsoletes)
-        s->obsoletes = source->idarraydata + deps[i].obsoletes;
-      if (deps[i].recommends)
-        s->recommends = source->idarraydata + deps[i].recommends;
-      if (deps[i].supplements)
-        s->supplements = source->idarraydata + deps[i].supplements;
-      if (deps[i].suggests)
-        s->suggests = source->idarraydata + deps[i].suggests;
-      if (deps[i].enhances)
-        s->enhances = source->idarraydata + deps[i].enhances;
-      if (deps[i].freshens)
-        s->freshens = source->idarraydata + deps[i].freshens;
+      s->provides = deps[i].provides;
+      s->requires = deps[i].requires;
+      s->conflicts = deps[i].conflicts;
+      s->obsoletes = deps[i].obsoletes;
+      s->recommends = deps[i].recommends;
+      s->supplements = deps[i].supplements;
+      s->suggests = deps[i].suggests;
+      s->enhances = deps[i].enhances;
+      s->freshens = deps[i].freshens;
     }
   free(deps);
   free(pd.content);
index 215ea23..3178312 100644 (file)
@@ -330,24 +330,15 @@ pool_addsource_susetags(Pool *pool, FILE *fp)
   s = pool->solvables + source->start;
   for (i = 0; i < pack; i++, s++)
     {
-      if (deps[i].provides)
-        s->provides = source->idarraydata + deps[i].provides;
-      if (deps[i].requires)
-        s->requires = source->idarraydata + deps[i].requires;
-      if (deps[i].conflicts)
-        s->conflicts = source->idarraydata + deps[i].conflicts;
-      if (deps[i].obsoletes)
-        s->obsoletes = source->idarraydata + deps[i].obsoletes;
-      if (deps[i].recommends)
-        s->recommends = source->idarraydata + deps[i].recommends;
-      if (deps[i].supplements)
-        s->supplements = source->idarraydata + deps[i].supplements;
-      if (deps[i].suggests)
-        s->suggests = source->idarraydata + deps[i].suggests;
-      if (deps[i].enhances)
-        s->enhances = source->idarraydata + deps[i].enhances;
-      if (deps[i].freshens)
-        s->freshens = source->idarraydata + deps[i].freshens;
+      s->provides = deps[i].provides;
+      s->requires = deps[i].requires;
+      s->conflicts = deps[i].conflicts;
+      s->obsoletes = deps[i].obsoletes;
+      s->recommends = deps[i].recommends;
+      s->supplements = deps[i].supplements;
+      s->suggests = deps[i].suggests;
+      s->enhances = deps[i].enhances;
+      s->freshens = deps[i].freshens;
     }
   free(deps);
   if (pd.tmp)
index f1680c0..d954992 100644 (file)
@@ -44,7 +44,7 @@ incneedid(Pool *pool, Id *idarray, NeedId *needid)
   Id id;
   int n = 0;
 
-  while ((id = *idarray++) != ID_NULL)
+  while ((id = *idarray++) != 0)
     {
       n++;
       while (ISRELDEP(id))
@@ -190,6 +190,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp)
   int nstrings, nrels;
   unsigned int sizeid;
   Reldep *ran;
+  Id *idarraydata;
 
   int idsizes[RPM_RPMDBID + 1];
   int bits, bitmaps;
@@ -197,6 +198,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp)
 
   nsolvables = source->nsolvables;
   sstart = pool->solvables + source->start;
+  idarraydata = source->idarraydata;
 
   needid = (NeedId *)calloc(pool->nstrings + pool->nrels, sizeof(*needid));
 
@@ -208,15 +210,24 @@ pool_writesource(Pool *pool, Source *source, FILE *fp)
       needid[s->name].need++;
       needid[s->arch].need++;
       needid[s->evr].need++;
-      idsizes[SOLVABLE_PROVIDES]    += incneedid(pool, s->provides, needid);
-      idsizes[SOLVABLE_REQUIRES]    += incneedid(pool, s->requires, needid);
-      idsizes[SOLVABLE_CONFLICTS]   += incneedid(pool, s->conflicts, needid);
-      idsizes[SOLVABLE_OBSOLETES]   += incneedid(pool, s->obsoletes, needid);
-      idsizes[SOLVABLE_RECOMMENDS]  += incneedid(pool, s->recommends, needid);
-      idsizes[SOLVABLE_SUGGESTS]    += incneedid(pool, s->suggests, needid);
-      idsizes[SOLVABLE_SUPPLEMENTS] += incneedid(pool, s->supplements, needid);
-      idsizes[SOLVABLE_ENHANCES]    += incneedid(pool, s->enhances, needid);
-      idsizes[SOLVABLE_FRESHENS]    += incneedid(pool, s->freshens, needid);
+      if (s->provides)
+        idsizes[SOLVABLE_PROVIDES]    += incneedid(pool, idarraydata + s->provides, needid);
+      if (s->requires)
+        idsizes[SOLVABLE_REQUIRES]    += incneedid(pool, idarraydata + s->requires, needid);
+      if (s->conflicts)
+        idsizes[SOLVABLE_CONFLICTS]   += incneedid(pool, idarraydata + s->conflicts, needid);
+      if (s->obsoletes)
+        idsizes[SOLVABLE_OBSOLETES]   += incneedid(pool, idarraydata + s->obsoletes, needid);
+      if (s->recommends)
+        idsizes[SOLVABLE_RECOMMENDS]  += incneedid(pool, idarraydata + s->recommends, needid);
+      if (s->suggests)
+        idsizes[SOLVABLE_SUGGESTS]    += incneedid(pool, idarraydata + s->suggests, needid);
+      if (s->supplements)
+        idsizes[SOLVABLE_SUPPLEMENTS] += incneedid(pool, idarraydata + s->supplements, needid);
+      if (s->enhances)
+        idsizes[SOLVABLE_ENHANCES]    += incneedid(pool, idarraydata + s->enhances, needid);
+      if (s->freshens)
+        idsizes[SOLVABLE_FRESHENS]    += incneedid(pool, idarraydata + s->freshens, needid);
     }
 
   idsizes[SOLVABLE_NAME] = 1;
@@ -234,9 +245,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp)
   needid[0].need = 0;
   needid[pool->nstrings].need = 0;
   for (i = 0; i < pool->nstrings + pool->nrels; i++)
-    {
-      needid[i].map = i;
-    }
+    needid[i].map = i;
 
   qsort(needid + 1, pool->nstrings - 1, sizeof(*needid), needid_cmp_need);
   qsort(needid + pool->nstrings, pool->nrels, sizeof(*needid), needid_cmp_need);
@@ -252,9 +261,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp)
 
   nstrings = i;
   for (i = 0; i < nstrings; i++)
-    {
-      needid[needid[i].map].need = i;
-    }
+    needid[needid[i].map].need = i;
 
   for (i = 0; i < pool->nrels; i++)
     {
@@ -381,23 +388,23 @@ pool_writesource(Pool *pool, Source *source, FILE *fp)
       write_id(fp, needid[s->evr].need);
 
       if (s->provides)
-        write_idarray(fp, pool, needid, s->provides);
+        write_idarray(fp, pool, needid, idarraydata + s->provides);
       if (s->obsoletes)
-        write_idarray(fp, pool, needid, s->obsoletes);
+        write_idarray(fp, pool, needid, idarraydata + s->obsoletes);
       if (s->conflicts)
-        write_idarray(fp, pool, needid, s->conflicts);
+        write_idarray(fp, pool, needid, idarraydata + s->conflicts);
       if (s->requires)
-        write_idarray(fp, pool, needid, s->requires);
+        write_idarray(fp, pool, needid, idarraydata + s->requires);
       if (s->recommends)
-        write_idarray(fp, pool, needid, s->recommends);
+        write_idarray(fp, pool, needid, idarraydata + s->recommends);
       if (s->suggests)
-        write_idarray(fp, pool, needid, s->suggests);
+        write_idarray(fp, pool, needid, idarraydata + s->suggests);
       if (s->supplements)
-        write_idarray(fp, pool, needid, s->supplements);
+        write_idarray(fp, pool, needid, idarraydata + s->supplements);
       if (s->enhances)
-        write_idarray(fp, pool, needid, s->enhances);
+        write_idarray(fp, pool, needid, idarraydata + s->enhances);
       if (s->freshens)
-        write_idarray(fp, pool, needid, s->freshens);
+        write_idarray(fp, pool, needid, idarraydata + s->freshens);
       if (source->rpmdbid)
         write_u32(fp, source->rpmdbid[i]);
     }