From 0a6671cb060e85d8246940f04480eaa890e2b373 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Wed, 9 Feb 2000 02:58:17 +0000 Subject: [PATCH] * clean up the conflicts/replaces, use an array of pkginfo pointers instead of the obsolete conflict struct. saves memory, faster...what more could you want. --- include/dpkg-db.h | 5 ----- main/archives.c | 6 +++--- main/archives.h | 2 +- main/processarc.c | 28 ++++++++++++++-------------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/include/dpkg-db.h b/include/dpkg-db.h index 4fab1f7b..1820a413 100644 --- a/include/dpkg-db.h +++ b/include/dpkg-db.h @@ -72,11 +72,6 @@ struct deppossi { int cyclebreak; }; -struct conflict { - struct pkginfo *cflict; - struct conflict *next; -}; - struct arbitraryfield { struct arbitraryfield *next; char *name; diff --git a/main/archives.c b/main/archives.c index bbcae79e..6cc61eb9 100644 --- a/main/archives.c +++ b/main/archives.c @@ -43,7 +43,7 @@ #include "archives.h" /* We shouldn't need anymore than 10 conflictors */ -struct conflict conflictor[10]; +struct pkginfo *conflictor[20]; int cflict_index = 0; int filesavespackage(struct fileinlist *file, struct pkginfo *pkgtobesaved, @@ -658,9 +658,9 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg, /* if this gets triggered, it means a package has > 10 conflicts/replaces * pairs, which is the package's fault */ - assert(cflict_index < 10); + assert(cflict_index < sizeof(conflictor)); /* This conflict is OK - we'll remove the conflictor. */ - conflictor[cflict_index++].cflict= fixbyrm; + conflictor[cflict_index++]= fixbyrm; varbuffree(&conflictwhy); varbuffree(&removalwhy); fprintf(stderr, _("dpkg: yes, will remove %s in favour of %s.\n"), fixbyrm->name, pkg->name); diff --git a/main/archives.h b/main/archives.h index 39a1f2fc..a8464264 100644 --- a/main/archives.h +++ b/main/archives.h @@ -34,7 +34,7 @@ extern struct varbuf fnametmpvb; extern struct varbuf fnamenewvb; extern struct packageinlist *deconfigure; -extern struct conflict conflictor[]; +extern struct pkginfo *conflictor[]; extern int cflict_index; void cu_pathname(int argc, void **argv); diff --git a/main/processarc.c b/main/processarc.c index a32261ab..e073df7b 100644 --- a/main/processarc.c +++ b/main/processarc.c @@ -345,7 +345,7 @@ void process_archive(const char *filename) { */ oldconffsetflags(pkg->installed.conffiles); for (i = 0 ; i < cflict_index ; i++) { - oldconffsetflags(conflictor[i].cflict->installed.conffiles); + oldconffsetflags(conflictor[i]->installed.conffiles); } oldversionstatus= pkg->status; @@ -367,11 +367,11 @@ void process_archive(const char *filename) { } for (i = 0 ; i < cflict_index ; i++) { - if (!(conflictor[i].cflict->status == stat_halfconfigured || - conflictor[i].cflict->status == stat_installed)) continue; + if (!(conflictor[i]->status == stat_halfconfigured || + conflictor[i]->status == stat_installed)) continue; for (deconpil= deconfigure; deconpil; deconpil= deconpil->next) { printf(_("De-configuring %s, so that we can remove %s ...\n"), - deconpil->pkg->name, conflictor[i].cflict->name); + deconpil->pkg->name, conflictor[i]->name); deconpil->pkg->status= stat_halfconfigured; modstatdb_note(deconpil->pkg); /* This means that we *either* go and run postinst abort-deconfigure, @@ -381,27 +381,27 @@ void process_archive(const char *filename) { push_cleanup(cu_prermdeconfigure,~ehflag_normaltidy, ok_prermdeconfigure,ehflag_normaltidy, 3,(void*)deconpil->pkg, - (void*)conflictor[i].cflict,(void*)pkg); + (void*)conflictor[i],(void*)pkg); maintainer_script_installed(deconpil->pkg, PRERMFILE, "pre-removal", "deconfigure", "in-favour", pkg->name, versiondescribe(&pkg->available.version, vdew_nonambig), - "removing", conflictor[i].cflict->name, - versiondescribe(&conflictor[i].cflict->installed.version, + "removing", conflictor[i]->name, + versiondescribe(&conflictor[i]->installed.version, vdew_nonambig), (char*)0); } - conflictor[i].cflict->status= stat_halfconfigured; - modstatdb_note(conflictor[i].cflict); + conflictor[i]->status= stat_halfconfigured; + modstatdb_note(conflictor[i]); push_cleanup(cu_prerminfavour,~ehflag_normaltidy, 0,0, - 2,(void*)conflictor[i].cflict,(void*)pkg); - maintainer_script_installed(conflictor[i].cflict, PRERMFILE, "pre-removal", + 2,(void*)conflictor[i],(void*)pkg); + maintainer_script_installed(conflictor[i], PRERMFILE, "pre-removal", "remove", "in-favour", pkg->name, versiondescribe(&pkg->available.version, vdew_nonambig), (char*)0); - conflictor[i].cflict->status= stat_halfinstalled; - modstatdb_note(conflictor[i].cflict); + conflictor[i]->status= stat_halfinstalled; + modstatdb_note(conflictor[i]); } pkg->eflag |= eflagf_reinstreq; @@ -1011,7 +1011,7 @@ void process_archive(const char *filename) { for (i = 0 ; i < cflict_index ; i++) { /* We need to have the most up-to-date info about which files are what ... */ ensure_allinstfiles_available(); - removal_bulk(conflictor[i].cflict); + removal_bulk(conflictor[i]); } if (cipaction->arg == act_install) add_to_queue(pkg); -- 2.39.5