- move dep2str buffer into pool so that the memory gets released
authorMichael Schroeder <mls@suse.de>
Fri, 26 Oct 2007 20:42:46 +0000 (20:42 +0000)
committerMichael Schroeder <mls@suse.de>
Fri, 26 Oct 2007 20:42:46 +0000 (20:42 +0000)
- directly install translation solvables
- some minor code cleanups

package/libsatsolver.spec.in
src/pool.c
src/pool.h
src/poolid.c
src/solver.c

index a425cd2..593126e 100644 (file)
@@ -50,14 +50,14 @@ cd build
 make install DESTDIR=$RPM_BUILD_ROOT
 #rm -f %{buildroot}%{_libdir}/libsatsolver.la
 
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
+#%post -p /sbin/ldconfig
+#%postun -p /sbin/ldconfig
 
 %clean
 rm -rf "$RPM_BUILD_ROOT"
 
-%files
-%defattr(-,root,root)
+#%files
+#%defattr(-,root,root)
 
 %files devel
 %defattr(-,root,root)
index ac96e43..03ba5a2 100644 (file)
@@ -126,6 +126,8 @@ pool_free(Pool *pool)
   xfree(pool->stringspace);
   xfree(pool->strings);
   xfree(pool->rels);
+  for (i = 0; i < DEP2STRBUF; i++)
+    xfree(pool->dep2strbuf[i]);
   xfree(pool);
 }
 
index bf68ed0..1ed4770 100644 (file)
@@ -52,6 +52,11 @@ extern "C" {
 /* well known solvable */
 #define SYSTEMSOLVABLE         1
 
+
+/* how many strings to maintain (round robin) */
+#define DEP2STRBUF 16
+
+
 //-----------------------------------------------
 
 struct _Pool {
@@ -92,6 +97,11 @@ struct _Pool {
 
   Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
   void *nscallbackdata;
+
+  /* our dep2str string space */
+  char *dep2strbuf[DEP2STRBUF];
+  int   dep2strlen[DEP2STRBUF];
+  int   dep2strn;
 };
 
 #define TYPE_ID                        1
index 53ad7ff..2a860cd 100644 (file)
@@ -241,24 +241,20 @@ dep2str(Pool *pool, Id id)
   char *s1, *s2;
   int n, l, ls1, ls2, lsr;
 
-  static char *dep2strbuf[DEP2STRBUF];
-  static int   dep2strlen[DEP2STRBUF];
-  static int   dep2strn;
-
   if (!ISRELDEP(id))
     return pool->stringspace + pool->strings[id];
   rd = GETRELDEP(pool, id);
-  n = dep2strn;
+  n = pool->dep2strn;
 
   sr = id2rel(pool, id);
   lsr = strlen(sr);
 
   s2 = (char *)dep2str(pool, rd->evr);
-  dep2strn = n;
+  pool->dep2strn = n;
   ls2 = strlen(s2);
 
   s1 = (char *)dep2str(pool, rd->name);
-  dep2strn = n;
+  pool->dep2strn = n;
   ls1 = strlen(s1);
 
   if (rd->flags == REL_NAMESPACE)
@@ -269,34 +265,34 @@ dep2str(Pool *pool, Id id)
     }
 
   l = ls1 + ls2 + lsr;
-  if (l + 1 > dep2strlen[n])
+  if (l + 1 > pool->dep2strlen[n])
     {
-      if (s1 != dep2strbuf[n])
-        dep2strbuf[n] = xrealloc(dep2strbuf[n], l + 32);
+      if (s1 != pool->dep2strbuf[n])
+        pool->dep2strbuf[n] = xrealloc(pool->dep2strbuf[n], l + 32);
       else
        {
-          dep2strbuf[n] = xrealloc(dep2strbuf[n], l + 32);
-          s1 = dep2strbuf[n];
+          pool->dep2strbuf[n] = xrealloc(pool->dep2strbuf[n], l + 32);
+          s1 = pool->dep2strbuf[n];
        }
-      dep2strlen[n] = l + 32;
+      pool->dep2strlen[n] = l + 32;
     }
-  if (s1 != dep2strbuf[n])
+  if (s1 != pool->dep2strbuf[n])
     {
-      strcpy(dep2strbuf[n], s1);
-      s1 = dep2strbuf[n];
+      strcpy(pool->dep2strbuf[n], s1);
+      s1 = pool->dep2strbuf[n];
     }
   strcpy(s1 + ls1, sr);
-  dep2strbuf[n] = s1 + ls1 + lsr;
+  pool->dep2strbuf[n] = s1 + ls1 + lsr;
   s2 = (char *)dep2str(pool, rd->evr);
-  if (s2 != dep2strbuf[n])
-    strcpy(dep2strbuf[n], s2);
-  dep2strbuf[n] = s1;
+  if (s2 != pool->dep2strbuf[n])
+    strcpy(pool->dep2strbuf[n], s2);
+  pool->dep2strbuf[n] = s1;
   if (rd->flags == REL_NAMESPACE)
     {
       s1[ls1 + ls2 + lsr - 1] = ')';
       s1[ls1 + ls2 + lsr] = 0;
     }
-  dep2strn = (n + 1) % DEP2STRBUF;
+  pool->dep2strn = (n + 1) % DEP2STRBUF;
   return s1;
 }
 
index ef007b6..9459a0f 100644 (file)
@@ -508,31 +508,28 @@ unifyrules(Solver *solv)
   solv->rules = (Rule *)xrealloc(solv->rules, ((solv->nrules + RULES_BLOCK) & ~RULES_BLOCK) * sizeof(Rule));
   solv->nrules = j;
 #if 1
-  {
-    int binr = 0;
-    int dc = 0;
-    Id *dp;
-    Rule *r;
+  if (solv->pool->verbose)
+    {
+      int binr = 0;
+      int lits = 0;
+      Id *dp;
+      Rule *r;
 
-    for (i = 1; i < solv->nrules; i++)
-      {
-       r = solv->rules + i;
-       if (r->d == 0)                 /* assertion */
-         {
+      for (i = 1; i < solv->nrules; i++)
+       {
+         r = solv->rules + i;
+         if (r->d == 0)
            binr++;
-           continue;
-         }
-        dp = solv->pool->whatprovidesdata + r->d;
-       while (*dp++)
-         dc++;
-      }
-    if (solv->pool->verbose)
-      {
-        printf("  binary: %d\n", binr);
-        printf("  normal: %d\n", solv->nrules - 1 - binr);
-        printf("  normal lits: %d\n", dc);
-      }
-  }
+         else
+           {
+             dp = solv->pool->whatprovidesdata + r->d;
+             while (*dp++)
+               lits++;
+           }
+       }
+      printf("  binary: %d\n", binr);
+      printf("  normal: %d, %d literals\n", solv->nrules - 1 - binr, lits);
+    }
 #endif
 }
 
@@ -627,7 +624,8 @@ addrule(Solver *solv, Id p, Id d)
       if (!solv->jobrules)
        {
          /* this is a rpm rule assertion, we do not have to allocate it */
-          /* it can be identified by a level of 1 and a zero reason */
+         /* it can be identified by a level of 1 and a zero reason */
+         /* we must not drop those rules from the decisionq when rewinding! */
          if (p > 0)
            abort();
          if (solv->decisionmap[-p] > 0 || solv->decisionmap[-p] < -1)
@@ -848,9 +846,12 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
              if (req == SOLVABLE_PREREQMARKER)   /* skip the marker */
                continue;
 
-             dp = GET_PROVIDESP(req, p);      /* get providers of req */
+             dp = GET_PROVIDESP(req, p);       /* get providers of req */
 
-             if (dontfix)             /* dont care about breakage */
+             if (*dp == SYSTEMSOLVABLE)        /* always installed */
+               continue;
+
+             if (dontfix)
                {
                  /* the strategy here is to not insist on dependencies
                    * that are already broken. so if we find one provider
@@ -859,9 +860,9 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
                  for (i = 0; dp[i]; i++)       /* for all providers */
                    {
                      if (dp[i] >= system->start && dp[i] < system->start + system->nsolvables)
-                       break;         /* provider is installed */
+                       break;          /* provider was installed */
                    }
-                 if (!dp[i])          /* previously broken dependency */
+                 if (!dp[i])           /* previously broken dependency */
                    {
                      if (pool->verbose) printf("ignoring broken requires %s of system package %s-%s.%s\n", dep2str(pool, req), id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch));
                      continue;
@@ -880,8 +881,6 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m)
                  continue;
                }
 
-             if (*dp == SYSTEMSOLVABLE)                /* always installed */
-               continue;
   #if 0
              printf("addrule %s-%s.%s %s %d %d\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), dep2str(pool, req), -n, dp - pool->whatprovidesdata);
              for (i = 0; dp[i]; i++)