tags 395140 patch
thanks

The following patch seems to reduce dselect memory usage by using a
smaller ncurses buffer size. Interactive performance is useable again
on my 32MB test box.

Thanks,

-- 
Michel "Walken" Lespinasse
"Bill Gates is a monocle and a Persian cat away from being the villain
in a James Bond movie." -- Dennis Miller
diff -ru dpkg-1.13.24.orig/dselect/baselist.cc dpkg-1.13.24/dselect/baselist.cc
--- dpkg-1.13.24.orig/dselect/baselist.cc       2006-06-21 06:41:12.000000000 
-0700
+++ dpkg-1.13.24/dselect/baselist.cc    2006-10-25 04:08:19.000000000 -0700
@@ -170,7 +170,7 @@
   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 -ru dpkg-1.13.24.orig/dselect/basetop.cc dpkg-1.13.24/dselect/basetop.cc
--- dpkg-1.13.24.orig/dselect/basetop.cc        2006-06-21 06:41:12.000000000 
-0700
+++ dpkg-1.13.24/dselect/basetop.cc     2006-10-25 04:23:55.000000000 -0700
@@ -39,7 +39,7 @@
                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::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 -ru dpkg-1.13.24.orig/dselect/pkglist.cc dpkg-1.13.24/dselect/pkglist.cc
--- dpkg-1.13.24.orig/dselect/pkglist.cc        2006-06-21 06:41:12.000000000 
-0700
+++ dpkg-1.13.24/dselect/pkglist.cc     2006-10-25 04:24:09.000000000 -0700
@@ -340,15 +340,7 @@
   }
 
   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 -ru dpkg-1.13.24.orig/dselect/pkgtop.cc dpkg-1.13.24/dselect/pkgtop.cc
--- dpkg-1.13.24.orig/dselect/pkgtop.cc 2006-06-21 06:41:12.000000000 -0700
+++ dpkg-1.13.24/dselect/pkgtop.cc      2006-10-25 03:47:51.000000000 -0700
@@ -139,6 +139,7 @@
   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 @@
 
     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 @@
       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,7 @@
       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 +199,22 @@
 
     }
 
-    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_never));
     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_never));
       wattrset(listpad, selected ? listsel_attr : list_attr);
@@ -235,7 +236,7 @@
     
     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--; }

Reply via email to