summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@zoy.org>2008-07-06 20:45:48 +0200
committerRaphael Hertzog <hertzog@debian.org>2008-07-06 20:46:31 +0200
commitcf6b114b9b21840a55d5618910be6f4db1a9295c (patch)
treefb10d1b994af2a9155a40c9022bf4fe3f59b11b3
parent4174eea758751055dc36caf3941368fe12148bd9 (diff)
downloaddpkg-cf6b114b9b21840a55d5618910be6f4db1a9295c.tar.gz
Reduce dselect memory usage
* dselect/baselist.cc (baselist::startdisplay): Create the pad with the list of the size of the display and not of the size of the list content itself. * dselect/basetop.cc (baselist::refreshlist): The part to display is always at the top of the pad. (baselist::redrawitemsrange): Simplified to redraw the real range only. * dselect/pkglist.cc (packagelist::sortmakeheads): No need to reallocate the pad when the list changes. * dselect/pkgtop.cc (packagelist::redraw1itemsel): The line of the item in the infopad doesn't correspond to its index in the list any more. Adjust accordingly.
-rw-r--r--ChangeLog15
-rw-r--r--THANKS1
-rw-r--r--debian/changelog3
-rw-r--r--dselect/baselist.cc2
-rw-r--r--dselect/basetop.cc9
-rw-r--r--dselect/pkglist.cc10
-rw-r--r--dselect/pkgtop.cc20
7 files changed, 37 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index d00287653..a7a2094e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-07-06 Michel Lespinasse <walken@zoy.org>
+
+ * dselect/baselist.cc (baselist::startdisplay): Create the
+ pad with the list of the size of the display and not of the
+ size of the list content itself.
+ * dselect/basetop.cc (baselist::refreshlist): The part to
+ display is always at the top of the pad.
+ (baselist::redrawitemsrange): Simplified to redraw the real
+ range only.
+ * dselect/pkglist.cc (packagelist::sortmakeheads): No need to reallocate
+ the pad when the list changes.
+ * dselect/pkgtop.cc (packagelist::redraw1itemsel): The line
+ of the item in the infopad doesn't correspond to its index in
+ the list any more. Adjust accordingly.
+
2008-07-05 Guillem Jover <guillem@debian.org>
* src/archives.c (filesavespackage): Do not mark debug message for
diff --git a/THANKS b/THANKS
index 9fe83024e..81fd913b6 100644
--- a/THANKS
+++ b/THANKS
@@ -121,6 +121,7 @@ Michael Alan Dorman <mdorman@calder.med.miami.edu>
Michael Shields <shields@crosslink.net>
Michael Sobolev <mss@transas.com>
Michael Vogt <mvo@ubuntu.com>
+Michel Lespinasse <walken@zoy.org>
Miguel Figueiredo <elmig@debianpt.org>
Miquel van Smoorenburg <miquels@cistron.nl>
Miroslav Kure <kurem@debian.cz>
diff --git a/debian/changelog b/debian/changelog
index 40bbb8983..eecb539a3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -64,6 +64,9 @@ dpkg (1.15.0) UNRELEASED; urgency=low
Thanks to Thomas Hood <jdthood@yahoo.co.uk>. Closes: #107098
* Use description of installed package as fallback in dselect.
Based on a patch from Bruce Sass <bmsass@shaw.ca>. Closes: #21659
+ * Reduce memory usage of dselect by avoiding usage of a big infopad.
+ Thanks to Michel Lespinasse <walken@zoy.org> for the patch.
+ Closes: #395140
[ Pierre Habouzit ]
* Add a --query option to update-alternatives. Closes: #336091, #441904
diff --git a/dselect/baselist.cc b/dselect/baselist.cc
index e7768a3fb..82ce4fa2c 100644
--- a/dselect/baselist.cc
+++ b/dselect/baselist.cc
@@ -171,7 +171,7 @@ void baselist::startdisplay() {
if (!whatinfowin) ohshite(_("failed to create whatinfo window"));
wattrset(whatinfowin,whatinfo_attr);
- listpad= newpad(nitems+1, total_width);
+ listpad = newpad(ymax, total_width);
if (!listpad) ohshite(_("failed to create baselist pad"));
colheadspad= newpad(1, total_width);
diff --git a/dselect/basetop.cc b/dselect/basetop.cc
index 6297ba89e..85b63ed2b 100644
--- a/dselect/basetop.cc
+++ b/dselect/basetop.cc
@@ -39,7 +39,7 @@ void baselist::refreshlist() {
list_row + nitems - topofscreen - 1);
x= lesserint(total_width - leftofscreen - 1,
xmax - 1);
- pnoutrefresh(listpad, topofscreen,leftofscreen, list_row,0, y,x);
+ pnoutrefresh(listpad, 0, leftofscreen, list_row, 0, y, x);
getmaxyx(listpad,maxy,maxx);
y++;
while (y < list_row + list_height - 1) {
@@ -49,9 +49,10 @@ void baselist::refreshlist() {
}
void baselist::redrawitemsrange(int start, int end) {
- if (ldrawnstart==-1) { ldrawnstart= ldrawnend= end; }
- while (ldrawnstart > start) { ldrawnstart--; redraw1item(ldrawnstart); }
- while (ldrawnend < end) { redraw1item(ldrawnend); ldrawnend++; }
+ int i;
+ for (i = start; i < end; i++) {
+ redraw1item(i);
+ }
}
void baselist::refreshcolheads() {
diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc
index 53bf43a57..062181953 100644
--- a/dselect/pkglist.cc
+++ b/dselect/pkglist.cc
@@ -344,15 +344,7 @@ void packagelist::sortmakeheads() {
}
if (listpad) {
- int maxx, maxy;
- getmaxyx(listpad,maxx,maxy);
- if (nitems > maxy) {
- delwin(listpad);
- listpad= newpad(nitems+1, total_width);
- if (!listpad) ohshite("failed to create larger baselist pad");
- } else if (nitems < maxy) {
- werase(listpad);
- }
+ werase(listpad);
}
sortinplace();
diff --git a/dselect/pkgtop.cc b/dselect/pkgtop.cc
index 3022c50b2..8876e7db3 100644
--- a/dselect/pkgtop.cc
+++ b/dselect/pkgtop.cc
@@ -139,6 +139,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
const char *p;
const struct pkginfo *pkg= table[index]->pkg;
const struct pkginfoperfile *info= &pkg->available;
+ int screenline = index - topofscreen;
wattrset(listpad, selected ? listsel_attr : list_attr);
@@ -146,7 +147,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
if (verbose) {
- mvwprintw(listpad,index,0, "%-*.*s ",
+ mvwprintw(listpad, screenline, 0, "%-*.*s ",
status_hold_width, status_hold_width,
gettext(eflagstrings[pkg->eflag]));
wprintw(listpad, "%-*.*s ",
@@ -164,14 +165,14 @@ void packagelist::redraw1itemsel(int index, int selected) {
wattrset(listpad, selected ? listsel_attr : list_attr);
waddch(listpad, ' ');
- mvwprintw(listpad,index,priority_column-1, " %-*.*s",
+ mvwprintw(listpad, screenline, priority_column - 1, " %-*.*s",
priority_width, priority_width,
pkg->priority == pkginfo::pri_other ? pkg->otherpriority :
gettext(prioritystrings[pkg->priority]));
} else {
- mvwaddch(listpad,index,0, eflagchars[pkg->eflag]);
+ mvwaddch(listpad, screenline, 0, eflagchars[pkg->eflag]);
waddch(listpad, statuschars[pkg->status]);
waddch(listpad,
/* fixme: keep this feature? */
@@ -182,7 +183,8 @@ void packagelist::redraw1itemsel(int index, int selected) {
waddch(listpad, wantchars[table[index]->selected]);
wattrset(listpad, selected ? listsel_attr : list_attr);
- wmove(listpad,index,priority_column-1); waddch(listpad,' ');
+ wmove(listpad, screenline, priority_column - 1);
+ waddch(listpad, ' ');
if (pkg->priority == pkginfo::pri_other) {
int i;
const char *p;
@@ -198,22 +200,22 @@ void packagelist::redraw1itemsel(int index, int selected) {
}
- mvwprintw(listpad,index,section_column-1, " %-*.*s",
+ mvwprintw(listpad, screenline, section_column - 1, " %-*.*s",
section_width, section_width,
pkg->section ? pkg->section : "?");
- mvwprintw(listpad,index,package_column-1, " %-*.*s ",
+ mvwprintw(listpad, screenline, package_column - 1, " %-*.*s ",
package_width, package_width, pkg->name);
if (versioninstalled_width)
- mvwprintw(listpad,index,versioninstalled_column, "%-*.*s ",
+ mvwprintw(listpad, screenline, versioninstalled_column, "%-*.*s ",
versioninstalled_width, versioninstalled_width,
versiondescribe(&pkg->installed.version, vdew_nonambig));
if (versionavailable_width) {
if (informativeversion(&pkg->available.version) &&
versioncompare(&pkg->available.version,&pkg->installed.version) > 0)
wattrset(listpad, selected ? selstatesel_attr : selstate_attr);
- mvwprintw(listpad,index,versionavailable_column, "%-*.*s",
+ mvwprintw(listpad, screenline, versionavailable_column, "%-*.*s",
versionavailable_width, versionavailable_width,
versiondescribe(&pkg->available.version, vdew_nonambig));
wattrset(listpad, selected ? listsel_attr : list_attr);
@@ -236,7 +238,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
indent= describemany(buf,priority,section,pkg->clientdata);
- mvwaddstr(listpad,index,0, " ");
+ mvwaddstr(listpad, screenline, 0, " ");
i= total_width-7;
j= (indent<<1) + 1;
while (j-- >0) { waddch(listpad,ACS_HLINE); i--; }