Explorar o código

Switch ad-hoc code to use struct pkg_list data type

Free the trig_awaited_pend_head list now that it is a pkg_list and
it switched from being allocated with m_malloc instead of nfmalloc.
Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
1a8cda208d
Modificáronse 6 ficheiros con 25 adicións e 36 borrados
  1. 4 10
      lib/dpkg/triglib.c
  2. 1 1
      src/help.c
  3. 4 6
      src/main.c
  4. 7 10
      src/main.h
  5. 8 8
      src/packages.c
  6. 1 1
      src/trigproc.c

+ 4 - 10
lib/dpkg/triglib.c

@@ -34,6 +34,7 @@
 
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg-list.h>
 #include <dpkg/dlist.h>
 
 const char *
@@ -172,12 +173,6 @@ trig_clear_awaiters(struct pkginfo *notpend)
 	}
 }
 
-/* FIXME: switch to use the generic pkg list for lenny+1 */
-struct pkg_list {
-	struct pkg_list *next;
-	struct pkginfo *pkg;
-};
-
 static struct pkg_list *trig_awaited_pend_head;
 
 void
@@ -189,10 +184,7 @@ trig_enqueue_awaited_pend(struct pkginfo *pend)
 		if (tp->pkg == pend)
 			return;
 
-	tp = nfmalloc(sizeof(*tp));
-	tp->pkg = pend;
-	tp->next = trig_awaited_pend_head;
-	trig_awaited_pend_head = tp;
+	pkg_list_prepend(&trig_awaited_pend_head, pend);
 }
 
 /*
@@ -215,6 +207,8 @@ trig_fixup_awaiters(enum modstatdb_rw cstatus)
 	for (tp = trig_awaited_pend_head; tp; tp = tp->next)
 		if (!tp->pkg->trigpend_head)
 			trig_clear_awaiters(tp->pkg);
+
+	pkg_list_free(trig_awaited_pend_head);
 	trig_awaited_pend_head = NULL;
 }
 

+ 1 - 1
src/help.c

@@ -130,7 +130,7 @@ void checkpath(void) {
 }
 
 int ignore_depends(struct pkginfo *pkg) {
-  struct pkginqueue *id;
+  struct pkg_list *id;
   for (id= ignoredependss; id; id= id->next)
     if (id->pkg == pkg) return 1;
   return 0;

+ 4 - 6
src/main.c

@@ -182,7 +182,7 @@ int fc_badverify = 0;
 int errabort = 50;
 const char *admindir= ADMINDIR;
 const char *instdir= "";
-struct pkginqueue *ignoredependss = NULL;
+struct pkg_list *ignoredependss = NULL;
 
 static const struct forceinfo {
   const char *name;
@@ -266,7 +266,6 @@ static void setroot(const struct cmdinfo *cip, const char *value) {
 static void ignoredepends(const struct cmdinfo *cip, const char *value) {
   char *copy, *p;
   const char *pnerr;
-  struct pkginqueue *ni;
 
   copy= m_malloc(strlen(value)+2);
   strcpy(copy,value);
@@ -283,10 +282,9 @@ static void ignoredepends(const struct cmdinfo *cip, const char *value) {
     pnerr = illegal_packagename(p, NULL);
     if (pnerr) ohshite(_("--ignore-depends requires a legal package name. "
                        "`%.250s' is not; %s"), p, pnerr);
-    ni = m_malloc(sizeof(struct pkginqueue));
-    ni->pkg= findpackage(p);
-    ni->next= ignoredependss;
-    ignoredependss= ni;
+
+    pkg_list_prepend(&ignoredependss, findpackage(p));
+
     p+= strlen(p)+1;
   }
 }

+ 7 - 10
src/main.h

@@ -22,6 +22,8 @@
 #ifndef MAIN_H
 #define MAIN_H
 
+#include <dpkg/pkg-list.h>
+
 struct fileinlist; /* these two are defined in filesdb.h */
 struct filenamenode;
 
@@ -43,12 +45,7 @@ struct perpackagestate {
   int replacingfilesandsaid;
 
   /* Non-NULL iff in trigproc.c:deferred. */
-  struct pkginqueue *trigprocdeferred;
-};
-
-struct pkginqueue {
-  struct pkginqueue *next;
-  struct pkginfo *pkg;
+  struct pkg_list *trigprocdeferred;
 };
 
 enum action {
@@ -130,7 +127,7 @@ extern int abort_processing;
 extern int errabort;
 extern const char *admindir;
 extern const char *instdir;
-extern struct pkginqueue *ignoredependss;
+extern struct pkg_list *ignoredependss;
 extern const char architecture[];
 
 struct invoke_hook {
@@ -199,14 +196,14 @@ void deferred_configure(struct pkginfo *pkg);
 extern int sincenothing, dependtry;
 
 struct pkgqueue {
-  struct pkginqueue *head, **tail;
+  struct pkg_list *head, **tail;
   int length;
 };
 
 #define PKGQUEUE_DEF_INIT(name) struct pkgqueue name = { NULL, &name.head, 0 }
 
-struct pkginqueue *add_to_some_queue(struct pkginfo *pkg, struct pkgqueue *q);
-struct pkginqueue *remove_from_some_queue(struct pkgqueue *q);
+struct pkg_list *add_to_some_queue(struct pkginfo *pkg, struct pkgqueue *q);
+struct pkg_list *remove_from_some_queue(struct pkgqueue *q);
 
 /* from cleanup.c (most of these are declared in archives.h) */
 

+ 8 - 8
src/packages.c

@@ -38,6 +38,7 @@
 
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
+#include <dpkg/pkg-list.h>
 #include <dpkg/myopt.h>
 
 #include "filesdb.h"
@@ -48,14 +49,13 @@ static PKGQUEUE_DEF_INIT(queue);
 
 int sincenothing = 0, dependtry = 0;
 
-struct pkginqueue *
+struct pkg_list *
 add_to_some_queue(struct pkginfo *pkg, struct pkgqueue *q)
 {
-  struct pkginqueue *newent;
+  struct pkg_list *newent;
+
+  newent = pkg_list_new(pkg, NULL);
 
-  newent= m_malloc(sizeof(struct pkginqueue));
-  newent->pkg= pkg;
-  newent->next = NULL;
   *q->tail = newent;
   q->tail = &newent->next;
   q->length++;
@@ -63,10 +63,10 @@ add_to_some_queue(struct pkginfo *pkg, struct pkgqueue *q)
   return newent;
 }
 
-struct pkginqueue *
+struct pkg_list *
 remove_from_some_queue(struct pkgqueue *q)
 {
-  struct pkginqueue *removeent = q->head;
+  struct pkg_list *removeent = q->head;
 
   if (!removeent)
     return NULL;
@@ -167,7 +167,7 @@ void packages(const char *const *argv) {
 }
 
 void process_queue(void) {
-  struct pkginqueue *removeent, *rundown;
+  struct pkg_list *removeent, *rundown;
   struct pkginfo *volatile pkg;
   volatile enum action action_todo;
   jmp_buf ejbuf;

+ 1 - 1
src/trigproc.c

@@ -102,7 +102,7 @@ trigproc_enqueue_deferred(struct pkginfo *pend)
 void
 trigproc_run_deferred(void)
 {
-	struct pkginqueue *node;
+	struct pkg_list *node;
 	struct pkginfo *pkg;
 
 	debug(dbg_triggers, "trigproc_run_deferred");