struct MsgBuf_cache_entry *entry = cache->head;
struct MsgBuf_cache_entry *prev = NULL;
struct MsgBuf_cache_entry *result = NULL;
+ struct MsgBuf_cache_entry *tail = NULL;
int n = 0;
while (entry != NULL) {
break;
}
+ tail = prev;
prev = entry;
entry = entry->next;
n++;
} else {
/* Cache full, replace the last entry */
result = prev;
+ if (tail != NULL)
+ tail->next = NULL;
prev = NULL;
rb_linebuf_donebuf(&result->linebuf);