The following commit has been merged in the master branch:
commit 1a8cda208d2a515bc28e27085f54b6e1eabc3e32
Author: Guillem Jover <[email protected]>
Date:   Mon Sep 14 21:56:45 2009 +0200

    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.

diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index d4a91c5..7288dd6 100644
--- a/lib/dpkg/triglib.c
+++ b/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;
 }
 
diff --git a/src/help.c b/src/help.c
index a9eacdc..a0f8376 100644
--- a/src/help.c
+++ b/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;
diff --git a/src/main.c b/src/main.c
index 5fdc910..cda8380 100644
--- a/src/main.c
+++ b/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;
   }
 }
diff --git a/src/main.h b/src/main.h
index 59214ae..698c9c6 100644
--- a/src/main.h
+++ b/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) */
 
diff --git a/src/packages.c b/src/packages.c
index a9983c4..d9badd8 100644
--- a/src/packages.c
+++ b/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;
diff --git a/src/trigproc.c b/src/trigproc.c
index 96b12c0..3b6bdfb 100644
--- a/src/trigproc.c
+++ b/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");

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to