[ekg2-commit] r3908 - trunk/ekg: trunk/ekg/stuff.c
SVN commit
svn w toxygen.net
Sob, 15 Mar 2008, 23:26:13 CET
Author: peres
Date: 2008-03-15 23:26:13 +0100 (Sat, 15 Mar 2008)
New Revision: 3908
Modified:
trunk/ekg/stuff.c
Log:
I just forgot that n might be 0. Now everything shall work fine.
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-03-15 20:05:52 UTC (rev 3907)
+++ trunk/ekg/stuff.c 2008-03-15 22:26:13 UTC (rev 3908)
@@ -458,7 +458,8 @@
}
inline static void buffer_add_common(struct buffer_info *type, const char *target, const char *line, time_t ts) {
- struct buffer *b, **addpoint = &(type->last);
+ struct buffer *b;
+ struct buffer **addpoint = (type->last ? &(type->last) : &(type->data));
/* What the heck with addpoint thing?
* - if type->last ain't NULL, it points to last element of the list;
@@ -473,23 +474,19 @@
*/
if (type->max_lines) { /* XXX: move to idles? */
+bac_countupd:
b = type->data;
int n = type->count - type->max_lines + 1;
if (n > 0) { /* list slice removal */
b = LIST_GET_NTH2(b, n); /* last element to remove */
- if (b) {
- type->data = b->next;
- b->next = NULL; /* unlink elements to be removed */
- type->count -= n;
- if (!*addpoint) /* no 'last'? then use beginning */
- addpoint = &(type->data);
- } else { /* failsafe */
- type->count = 0;
- b = type->data;
- type->data = NULL;
- addpoint = &(type->data);/* we need some &NULL here ( ; */
+ if (!b) { /* count has been broken */
+ type->count = LIST_COUNT2(type->data);
+ goto bac_countupd;
}
+ type->data = b->next;
+ b->next = NULL; /* unlink elements to be removed */
+ type->count -= n;
LIST_DESTROY2(b, list_buffer_free); /* and remove them */
}
}
@@ -502,10 +499,6 @@
LIST_ADD2(addpoint, b);
type->last = b;
-
- if (!type->data)
- type->data = b;
-
type->count++;
}
Więcej informacji o liście dyskusyjnej ekg2-commit