Przeglądaj źródła

dpkg: Refactor code into new clear_deconfigure_queue() function

Guillem Jover 14 lat temu
rodzic
commit
5eca0227ae
3 zmienionych plików z 15 dodań i 8 usunięć
  1. 12 0
      src/archives.c
  2. 1 0
      src/archives.h
  3. 2 8
      src/processarc.c

+ 12 - 0
src/archives.c

@@ -1206,6 +1206,18 @@ enqueue_deconfigure(struct pkginfo *pkg, struct pkginfo *pkg_removal)
   deconfigure = newdeconf;
 }
 
+void
+clear_deconfigure_queue(void)
+{
+  struct pkg_deconf_list *deconf, *deconf_next;
+
+  for (deconf = deconfigure; deconf; deconf = deconf_next) {
+    deconf_next = deconf->next;
+    free(deconf);
+  }
+  deconfigure = NULL;
+}
+
 /**
  * Try if we can deconfigure the package and queue it if so.
  *

+ 1 - 0
src/archives.h

@@ -45,6 +45,7 @@ extern struct varbuf fnametmpvb;
 extern struct varbuf fnamenewvb;
 extern struct pkg_deconf_list *deconfigure;
 
+void clear_deconfigure_queue(void);
 void enqueue_deconfigure(struct pkginfo *pkg, struct pkginfo *pkg_removal);
 void enqueue_conflictor(struct pkginfo *pkg, struct pkginfo *pkg_fixbyrm);
 

+ 2 - 8
src/processarc.c

@@ -440,7 +440,7 @@ void process_archive(const char *filename) {
   FILE *conff;
   struct filenamenode *namenode;
   struct stat stab, oldfs;
-  struct pkg_deconf_list *deconpil, *deconpiltemp;
+  struct pkg_deconf_list *deconpil;
   struct pkginfo *fixbytrigaw;
 
   cleanup_pkg_failed= cleanup_conflictor_failed= 0;
@@ -517,13 +517,7 @@ void process_archive(const char *filename) {
                 _("package architecture (%s) does not match system (%s)"),
                 pkg->available.arch->name, dpkg_arch_get(arch_native)->name);
 
-  for (deconpil= deconfigure;
-       deconpil;
-       deconpil= deconpiltemp) {
-    deconpiltemp= deconpil->next;
-    free(deconpil);
-  }
-  deconfigure = NULL;
+  clear_deconfigure_queue();
   clear_istobes();
 
   if (!wanttoinstall(pkg)) {