From 6f8cef248e1467595a932707eb9a9c53af2e8839 Mon Sep 17 00:00:00 2001 From: oroborus Date: Fri, 30 May 2008 17:03:33 +0000 Subject: - opravene memory leaky pomocou vlagrindu - sietovy protokol je navrhnuty tal aby client odsiselal info o tom, ze obdrzal spravu git-svn-id: http://opensvn.csie.org/tuxanci_ng@57 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/idManager.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/idManager.c') 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) ); -- cgit v1.2.3