diff --git a/src/server/user_mgr.c b/src/server/user_mgr.c
--- a/src/server/user_mgr.c
+++ b/src/server/user_mgr.c
@@ -17,6 +17,8 @@
along with DistRen. If not, see .
*/
+#include "common/config.h"
+
#include "user_mgr.h"
#include "common/asprintf.h"
@@ -29,7 +31,6 @@
#include
#include
-#include
#include
#include
#include
@@ -80,8 +81,10 @@ struct user *findUser(char *nameOfUser)
int low;
int middle;
int result;
+
high = user_mgr_info.user_array_size - 1;
low = 0;
+ result = -1;
for(middle = (low+high)/2; 1 == 1; middle = (low+high)/2)
{
@@ -89,9 +92,9 @@ struct user *findUser(char *nameOfUser)
while(user_mgr_info.user_array[middle].username == 0)
{
if(result < 0)
- middle--;
+ middle --;
else
- middle++;
+ middle ++;
}
// this is where the array is cut in half and the half that the nameOfUser is on is kept
@@ -142,6 +145,8 @@ int placeUser(int index, char *nameOfUse
int lower;
int total_moves;
+ total_moves = 0;
+
// I shift data in the array to create an open the space where the user should be added
// but first I figure out which way is the shortest
if(user_mgr_info.user_array[index].username != 0)
@@ -172,9 +177,9 @@ int placeUser(int index, char *nameOfUse
// add the user to the array
createUser(&user_mgr_info.user_array[index], nameOfUser);
- if(total_moves > 50){
+ if(total_moves > 50)
resize_user_array();
- }
+
return 1;
}
@@ -184,8 +189,10 @@ int addUser(char *nameOfUser)
int low;
int middle;
int result;
+
high = user_mgr_info.user_array_size - 1;
low = 0;
+ result = -1;
for(middle = (low+high)/2; 1 == 1; middle = (low+high)/2)
{