]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/newsearch.c
whowas: Use a ring buffer for the whowas records.
[irc/quakenet/newserv.git] / newsearch / newsearch.c
index 8bdb56c178311898b7b5d1a7a8218085f37a9e47..6d76342ceb7f5a8ec6b796d93e4ba3bfd98fb7ee 100644 (file)
@@ -603,7 +603,7 @@ int do_whowassearch(void *source, int cargc, char **cargv) {
 }
 
 void whowassearch_exe(struct searchNode *search, searchCtx *ctx) {
-  int matches = 0;
+  int i, matches = 0;
   whowas *ww;
   nick *sender = ctx->sender;
   senderNSExtern = sender;
@@ -613,10 +613,15 @@ void whowassearch_exe(struct searchNode *search, searchCtx *ctx) {
   /* The top-level node needs to return a BOOL */
   search=coerceNode(ctx, search, RETURNTYPE_BOOL);
 
-  for (ww = whowas_head; ww; ww = ww->next) {
+  for (i = whowasoffset; i < whowasoffset + WW_MAXENTRIES; i++) {
+    ww = &whowasrecs[i % WW_MAXENTRIES];
+
+    if (ww->type == WHOWAS_UNUSED)
+      continue;
+
     /* Note: We're passing the nick to the filter function. The original
      * whowas record is in the nick's ->next field. */
-    if ((search->exe)(ctx, search, ww->nick)) {
+    if ((search->exe)(ctx, search, &ww->nick)) {
       if (matches<limit)
         display(ctx, sender, ww);