From 1576ab143b15ce52c5f83f1122b47730512e59e7 Mon Sep 17 00:00:00 2001 From: "geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Mon, 27 Aug 2007 18:12:31 +0000 Subject: BUILD : 1.7.19 (1274) BUGS : 764 NOTES : Fixed firstuser/nextuser and first_uid/next_uid using the same globals thus being unable to be used at the same time git-svn-id: svn://svn.anope.org/anope/trunk@1274 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@992 5417fbe8-f217-4b02-8779-1006273d7864 --- src/users.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/users.c b/src/users.c index f97638662..c6fb4c1cf 100644 --- a/src/users.c +++ b/src/users.c @@ -350,6 +350,7 @@ static int next_index; User *firstuser(void) { next_index = 0; + current = NULL; while (next_index < 1024 && current == NULL) current = userlist[next_index++]; if (debug) @@ -395,34 +396,38 @@ User *find_byuid(const char *uid) return NULL; } +static User *current_uid; +static int next_index_uid; + User *first_uid(void) { - next_index = 0; - while (next_index < 1024 && current == NULL) { - current = userlist[next_index++]; + next_index_uid = 0; + current_uid = NULL; + while (next_index_uid < 1024 && current_uid == NULL) { + current_uid = userlist[next_index_uid++]; } if (debug >= 2) { alog("debug: first_uid() returning %s %s", - current ? current->nick : "NULL (end of list)", - current ? current->uid : ""); + current_uid ? current_uid->nick : "NULL (end of list)", + current_uid ? current_uid->uid : ""); } - return current; + return current_uid; } User *next_uid(void) { - if (current) - current = current->next; - if (!current && next_index < 1024) { - while (next_index < 1024 && current == NULL) - current = userlist[next_index++]; + if (current_uid) + current_uid = current_uid->next; + if (!current_uid && next_index_uid < 1024) { + while (next_index_uid < 1024 && current_uid == NULL) + current_uid = userlist[next_index_uid++]; } if (debug >= 2) { alog("debug: next_uid() returning %s %s", - current ? current->nick : "NULL (end of list)", - current ? current->uid : ""); + current_uid ? current_uid->nick : "NULL (end of list)", + current_uid ? current_uid->uid : ""); } - return current; + return current_uid; } Uid *new_uid(const char *nick, char *uid) -- cgit