diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-05-16 11:50:21 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-05-16 13:17:12 +0200 |
commit | 380435abdb627159553d8a44d60d0948ba101651 (patch) | |
tree | 9628f6d9de113155b643e8e8822dd150185836ee /src/lib | |
parent | 00af0e77e327d8ca8e1d78caaf0cfdd1251c0fd2 (diff) |
eo ptr ind: set generation counter range to [1;max-1]
- so we never generate an Eo Id equal to 0,
thus don't need to skip the first top table index anymore
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/eo/eo_ptr_indirection.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/eo/eo_ptr_indirection.c b/src/lib/eo/eo_ptr_indirection.c index b355370..7cf72fd 100644 --- a/src/lib/eo/eo_ptr_indirection.c +++ b/src/lib/eo/eo_ptr_indirection.c | |||
@@ -211,7 +211,7 @@ static _Eo_Ids_Table **_eo_ids_tables[MAX_MID_TABLE_ID] = { NULL }; | |||
211 | static _Eo_Table_Info current_table = { NULL, 0, 0 }; | 211 | static _Eo_Table_Info current_table = { NULL, 0, 0 }; |
212 | 212 | ||
213 | /* Next generation to use when assigning a new entry to a Eo pointer */ | 213 | /* Next generation to use when assigning a new entry to a Eo pointer */ |
214 | Generation_Counter _eo_generation_counter; | 214 | Generation_Counter _eo_generation_counter = 0; |
215 | 215 | ||
216 | /* Macro used to compose an Eo id */ | 216 | /* Macro used to compose an Eo id */ |
217 | #define EO_COMPOSE_ID(TABLE, INTER_TABLE, ENTRY, GENERATION) \ | 217 | #define EO_COMPOSE_ID(TABLE, INTER_TABLE, ENTRY, GENERATION) \ |
@@ -287,7 +287,7 @@ _search_tables() | |||
287 | _Eo_Ids_Table *table; | 287 | _Eo_Ids_Table *table; |
288 | _Eo_Id_Entry *entry; | 288 | _Eo_Id_Entry *entry; |
289 | 289 | ||
290 | for (Table_Index mid_table_id = 1; mid_table_id < MAX_MID_TABLE_ID; mid_table_id++) | 290 | for (Table_Index mid_table_id = 0; mid_table_id < MAX_MID_TABLE_ID; mid_table_id++) |
291 | { | 291 | { |
292 | if (!_eo_ids_tables[mid_table_id]) | 292 | if (!_eo_ids_tables[mid_table_id]) |
293 | { | 293 | { |
@@ -343,12 +343,14 @@ _eo_id_allocate(const _Eo *obj) | |||
343 | return 0; | 343 | return 0; |
344 | } | 344 | } |
345 | 345 | ||
346 | /* [1;max-1] thus we never generate an Eo_Id equal to 0 */ | ||
347 | _eo_generation_counter++; | ||
348 | if (_eo_generation_counter == MAX_GENERATIONS) | ||
349 | _eo_generation_counter = 1; | ||
346 | /* An entry was found - fill it */ | 350 | /* An entry was found - fill it */ |
347 | entry->ptr = (_Eo *)obj; | 351 | entry->ptr = (_Eo *)obj; |
348 | entry->active = 1; | 352 | entry->active = 1; |
349 | entry->generation = _eo_generation_counter; | 353 | entry->generation = _eo_generation_counter; |
350 | _eo_generation_counter++; | ||
351 | _eo_generation_counter %= MAX_GENERATIONS; | ||
352 | return EO_COMPOSE_ID(current_table.mid_table_id, | 354 | return EO_COMPOSE_ID(current_table.mid_table_id, |
353 | current_table.table_id, | 355 | current_table.table_id, |
354 | (entry - current_table.table->entries), | 356 | (entry - current_table.table->entries), |