summaryrefslogtreecommitdiff
path: root/src/idManager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/idManager.c')
-rw-r--r--src/idManager.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/idManager.c b/src/idManager.c
index ef46433..9c866c9 100644
--- a/src/idManager.c
+++ b/src/idManager.c
@@ -8,10 +8,12 @@
#include "idManager.h"
static list_t *listID;
+static int lastID;
void initListID()
{
listID = newList();
+ lastID = 0;
printf("init ID manger..\n");
}
@@ -43,7 +45,13 @@ int getNewID()
assert( listID != NULL );
do{
- ret = random() % MAX_ID + 1;
+ ret = ++lastID;
+
+ if( lastID > MAX_ID )
+ {
+ lastID = 0;
+ }
+
}while( isRegisterID(ret) != -1 );
addList(listID, newInt(ret) );