Commit cd9ff7f6b81d016c13cbc1b2ea6fa9ca93000219

Con Kolivas 2013-06-15T01:28:00

Only display as many device rows as the maximum live existed at any time.

diff --git a/cgminer.c b/cgminer.c
index b8bd5d6..a27a2c5 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -115,6 +115,8 @@ static int opt_devs_enabled;
 static bool opt_display_devs;
 static bool opt_removedisabled;
 int total_devices;
+int zombie_devs;
+static int most_devices;
 struct cgpu_info **devices;
 bool have_opencl;
 int mining_threads;
@@ -2219,7 +2221,7 @@ static void switch_logsize(void)
 			logstart = devcursor + 1;
 			logcursor = logstart + 1;
 		} else {
-			logstart = devcursor + total_devices + 1;
+			logstart = devcursor + most_devices + 1;
 			logcursor = logstart + 1;
 		}
 		unlock_curses();
@@ -7134,6 +7136,12 @@ struct _cgpu_devid_counter {
 	UT_hash_handle hh;
 };
 
+static void adjust_mostdevs(void)
+{
+	if (total_devices - zombie_devs > most_devices)
+		most_devices = total_devices - zombie_devs;
+}
+
 bool add_cgpu(struct cgpu_info *cgpu)
 {
 	static struct _cgpu_devid_counter *devids = NULL;
@@ -7161,6 +7169,8 @@ bool add_cgpu(struct cgpu_info *cgpu)
 		devices[total_devices + new_devices++] = cgpu;
 	else
 		devices[total_devices++] = cgpu;
+
+	adjust_mostdevs();
 	return true;
 }
 
@@ -7245,6 +7255,7 @@ static void hotplug_process()
 		applog(LOG_WARNING, "Hotplug: %s added %s %i", cgpu->drv->dname, cgpu->drv->name, cgpu->device_id);
 	}
 
+	adjust_mostdevs();
 	switch_logsize();
 }
 
diff --git a/miner.h b/miner.h
index 6fc82b8..bcc3c03 100644
--- a/miner.h
+++ b/miner.h
@@ -970,6 +970,7 @@ extern bool opt_scrypt;
 extern double total_secs;
 extern int mining_threads;
 extern int total_devices;
+extern int zombie_devs;
 extern struct cgpu_info **devices;
 extern int total_pools;
 extern struct pool **pools;
diff --git a/usbutils.c b/usbutils.c
index b226fc6..9fdb1ea 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1363,6 +1363,7 @@ static void release_cgpu(struct cgpu_info *cgpu)
 	if (cgpu->usbinfo.nodev)
 		return;
 
+	zombie_devs++;
 	total_count--;
 	drv_count[cgpu->drv->drv_id].count--;