Browse code

- fixed flag hash bug, reported by Tomas Mandys - fixed MAX_FLAG usage (flags no = MAX_FLAG+1 and not MAX_FLAG)

Andrei Pelinescu-Onciul authored on 08/02/2006 16:44:37
Showing 1 changed files
... ...
@@ -74,10 +74,10 @@ int flag_in_range( flag_t flag ) {
74 74
 #define FLAGS_NAME_HASH_ENTRIES		32
75 75
 
76 76
 struct flag_entry{
77
-	str name;
78
-	int no;
79 77
 	struct flag_entry* next;
80 78
 	struct flag_entry* prev;
79
+	str name;
80
+	int no;
81 81
 };
82 82
 
83 83
 
... ...
@@ -87,7 +87,7 @@ struct flag_hash_head{
87 87
 };
88 88
 
89 89
 static struct flag_hash_head  name2flags[FLAGS_NAME_HASH_ENTRIES];
90
-static unsigned char registered_flags[MAX_FLAG];
90
+static unsigned char registered_flags[MAX_FLAG+1];
91 91
 
92 92
 
93 93
 void init_named_flags()
... ...
@@ -191,9 +191,9 @@ int register_flag(char* name, int pos)
191 191
 		}
192 192
 	}else{
193 193
 		/* alloc an empty flag */
194
-		last_flag=crt_flag+MAX_FLAG;
194
+		last_flag=crt_flag+(MAX_FLAG+1);
195 195
 		for (; crt_flag!=last_flag; crt_flag++){
196
-			r=crt_flag%MAX_FLAG;
196
+			r=crt_flag%(MAX_FLAG+1);
197 197
 			if (registered_flags[r]==0){
198 198
 				pos=r;
199 199
 				break;