/*
- * charybdis - an advanced ircd.
- * Copyright (c) 2016 William Pitcock <nenolod@dereferenced.org>.
+ * solanum - an advanced ircd.
+ * Copyright (c) 2016 Ariadne Conill <ariadne@dereferenced.org>.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
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;
+ caps &= cache->overall_capmask;
+
while (entry != NULL) {
if (entry->caps == caps) {
/* Cache hit */
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);