Kaynağa Gözat

Move color member from struct pkginfo to struct perpackagestate

The only user of this field is in the dependency cycle detection,
only found under src/. So move it there where it belongs.
Guillem Jover 16 yıl önce
ebeveyn
işleme
be33d6deea
5 değiştirilmiş dosya ile 12 ekleme ve 6 silme
  1. 0 1
      lib/dpkg/database.c
  2. 0 1
      lib/dpkg/dpkg-db.h
  3. 4 4
      src/depcon.c
  4. 1 0
      src/filesdb.c
  5. 7 0
      src/main.h

+ 0 - 1
lib/dpkg/database.c

@@ -74,7 +74,6 @@ void blankpackage(struct pkginfo *pigp) {
   pigp->installed.valid= 0;
   pigp->available.valid= 0;
   pigp->clientdata= NULL;
-  pigp->color= white;
   pigp->trigaw.head = pigp->trigaw.tail = NULL;
   pigp->othertrigaw_head = NULL;
   pigp->trigpend_head = NULL;

+ 0 - 1
lib/dpkg/dpkg-db.h

@@ -176,7 +176,6 @@ struct pkginfo { /* pig */
   struct pkginfoperfile installed;
   struct pkginfoperfile available;
   struct perpackagestate *clientdata;
-  enum { white, gray, black } color;  /* used during cycle detection */
 
   struct {
     /* ->aw == this */

+ 4 - 4
src/depcon.c

@@ -104,9 +104,9 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
   struct deppossi *possi, *providelink;
   struct pkginfo *provider;
 
-  if (pkg->color == black)
+  if (pkg->clientdata->color == black)
     return false;
-  pkg->color = gray;
+  pkg->clientdata->color = gray;
   
   if (f_debug & dbg_depcondetail) {
     struct varbuf str_pkgs = VARBUF_INIT;
@@ -147,7 +147,7 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
     }
   }
   /* Nope, we didn't find a cycle to break. */
-  pkg->color = black;
+  pkg->clientdata->color = black;
   return false;
 }
 
@@ -159,7 +159,7 @@ findbreakcycle(struct pkginfo *pkg)
 	
   /* Clear the visited flag of all packages before we traverse them. */
   for (iter = iterpkgstart(); (tpkg=iterpkgnext(iter)); ) {
-    tpkg->color = white;
+    tpkg->clientdata->color = white;
   }
   iterpkgend(iter);
 

+ 1 - 0
src/filesdb.c

@@ -56,6 +56,7 @@ ensure_package_clientdata(struct pkginfo *pkg)
     return;
   pkg->clientdata = nfmalloc(sizeof(struct perpackagestate));
   pkg->clientdata->istobe = itb_normal;
+  pkg->clientdata->color = white;
   pkg->clientdata->fileslistvalid = 0;
   pkg->clientdata->files = NULL;
   pkg->clientdata->trigprocdeferred = NULL;

+ 7 - 0
src/main.h

@@ -31,6 +31,13 @@ struct perpackagestate {
     itb_normal, itb_remove, itb_installnew, itb_deconfigure, itb_preinstall
   } istobe;
 
+  /* Used during cycle detection. */
+  enum {
+    white,
+    gray,
+    black,
+  } color;
+
   /*   filelistvalid   files         meaning
    *       0             0           not read yet, must do so if want them
    *       0            !=0          read, but rewritten and now out of