Bläddra i källkod

dpkg: Use struct filelist instead of two fileinlist to track newconffiles

Guillem Jover 12 år sedan
förälder
incheckning
43af9a7184
3 ändrade filer med 20 tillägg och 13 borttagningar
  1. 8 4
      src/archives.c
  2. 5 2
      src/main.h
  3. 7 7
      src/unpack.c

+ 8 - 4
src/archives.c

@@ -1758,14 +1758,18 @@ wanttoinstall(struct pkginfo *pkg)
   }
 }
 
-struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
-				   struct filenamenode *namenode) {
+struct fileinlist *
+newconff_append(struct filenamenode_queue *queue,
+                struct filenamenode *namenode)
+{
   struct fileinlist *newconff;
 
   newconff= m_malloc(sizeof(struct fileinlist));
   newconff->next = NULL;
   newconff->namenode= namenode;
-  **newconffileslastp_io= newconff;
-  *newconffileslastp_io= &newconff->next;
+
+  *queue->tail = newconff;
+  queue->tail = &newconff->next;
+
   return newconff;
 }

+ 5 - 2
src/main.h

@@ -27,6 +27,7 @@
 
 /* These two are defined in filesdb.h. */
 struct fileinlist;
+struct filenamenode_queue;
 struct filenamenode;
 
 enum pkg_istobe {
@@ -149,8 +150,10 @@ struct invoke_hook {
 int archivefiles(const char *const *argv);
 void process_archive(const char *filename);
 bool wanttoinstall(struct pkginfo *pkg);
-struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
-				   struct filenamenode *namenode);
+
+struct fileinlist *
+newconff_append(struct filenamenode_queue *queue,
+                struct filenamenode *namenode);
 
 /* from update.c */
 

+ 7 - 7
src/unpack.c

@@ -426,9 +426,9 @@ void process_archive(const char *filename) {
   char *psize;
   const char *pfilename;
   struct fileinlist *newfileslist;
-  struct fileinlist *newconffiles;
-  struct fileinlist *newconff, **newconffileslastp;
+  struct fileinlist *newconff;
   struct fileinlist *cfile;
+  struct filenamenode_queue newconffiles;
   struct reversefilelistiter rlistit;
   struct conffile *searchconff, **iconffileslastp, *newiconff;
   struct dependency *dsearch, *newdeplist, **newdeplistlastp;
@@ -619,8 +619,8 @@ void process_archive(const char *filename) {
   trig_parse_ci(cidir, NULL, trig_cicb_statuschange_activate, pkg, &pkg->available);
 
   /* Read the conffiles, and copy the hashes across. */
-  newconffiles = NULL;
-  newconffileslastp = &newconffiles;
+  newconffiles.head = NULL;
+  newconffiles.tail = &newconffiles.head;
   push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
   strcpy(cidirrest,CONFFILESFILE);
   conff= fopen(cidir,"r");
@@ -639,7 +639,7 @@ void process_archive(const char *filename) {
       *p = '\0';
       namenode= findnamenode(conffilenamebuf, 0);
       namenode->oldhash= NEWCONFFILEFLAG;
-      newconff= newconff_append(&newconffileslastp, namenode);
+      newconff = newconff_append(&newconffiles, namenode);
 
       /* Let's see if any packages have this file. If they do we
        * check to see if they listed it as a conffile, and if they did
@@ -1104,7 +1104,7 @@ void process_archive(const char *filename) {
 	  debug(dbg_eachfile, "process_archive: old conff %s"
 		" is disappearing", namenode->name);
 	  namenode->flags |= fnnf_obs_conff;
-	  newconff_append(&newconffileslastp, namenode);
+	  newconff_append(&newconffiles, namenode);
 	  addfiletolist(&tc, namenode);
 	}
 	continue;
@@ -1215,7 +1215,7 @@ void process_archive(const char *filename) {
   /* We have to generate our own conffiles structure. */
   pkg->installed.conffiles = NULL;
   iconffileslastp = &pkg->installed.conffiles;
-  for (cfile= newconffiles; cfile; cfile= cfile->next) {
+  for (cfile = newconffiles.head; cfile; cfile = cfile->next) {
     newiconff= nfmalloc(sizeof(struct conffile));
     newiconff->next = NULL;
     newiconff->name= nfstrsave(cfile->namenode->name);