dumplog's saved_plines[]

Use a simple ring buffer instead of a flat array that needed to have
49 pointers shifted down a slot every time a pline message was issued.

'saved_plines[saved_pline_index]' is the oldest message in the buffer
and the next slot to use when adding a new one.
This commit is contained in:
PatR
2017-02-27 02:54:14 -08:00
parent 92c5a56364
commit f55da584f4
2 changed files with 38 additions and 11 deletions

View File

@@ -675,15 +675,17 @@ char *defquery;
STATIC_OVL void
dump_plines()
{
int i;
int i, j;
char buf[BUFSZ], **strp;
extern char *saved_plines[];
extern unsigned saved_pline_index;
Strcpy(buf, " ");
putstr(0, 0, "");
putstr(0, 0, "Latest messages:");
for (i = 0; i < DUMPLOG_MSG_COUNT; ++i) {
strp = &saved_plines[DUMPLOG_MSG_COUNT - 1 - i];
for (i = 0, j = (int) saved_pline_index; i < DUMPLOG_MSG_COUNT;
++i, j = (j + 1) % DUMPLOG_MSG_COUNT) {
strp = &saved_plines[j];
if (*strp) {
copynchars(&buf[1], *strp, BUFSZ - 1 - 1);
putstr(0, 0, buf);