From 380435abdb627159553d8a44d60d0948ba101651 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 16 May 2013 11:50:21 +0200 Subject: [PATCH] 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 --- src/lib/eo/eo_ptr_indirection.c | 10 ++++++---- 1 file 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 }; static _Eo_Table_Info current_table = { NULL, 0, 0 }; /* Next generation to use when assigning a new entry to a Eo pointer */ -Generation_Counter _eo_generation_counter; +Generation_Counter _eo_generation_counter = 0; /* Macro used to compose an Eo id */ #define EO_COMPOSE_ID(TABLE, INTER_TABLE, ENTRY, GENERATION) \ @@ -287,7 +287,7 @@ _search_tables() _Eo_Ids_Table *table; _Eo_Id_Entry *entry; - for (Table_Index mid_table_id = 1; mid_table_id < MAX_MID_TABLE_ID; mid_table_id++) + for (Table_Index mid_table_id = 0; mid_table_id < MAX_MID_TABLE_ID; mid_table_id++) { if (!_eo_ids_tables[mid_table_id]) { @@ -343,12 +343,14 @@ _eo_id_allocate(const _Eo *obj) return 0; } + /* [1;max-1] thus we never generate an Eo_Id equal to 0 */ + _eo_generation_counter++; + if (_eo_generation_counter == MAX_GENERATIONS) + _eo_generation_counter = 1; /* An entry was found - fill it */ entry->ptr = (_Eo *)obj; entry->active = 1; entry->generation = _eo_generation_counter; - _eo_generation_counter++; - _eo_generation_counter %= MAX_GENERATIONS; return EO_COMPOSE_ID(current_table.mid_table_id, current_table.table_id, (entry - current_table.table->entries), -- 2.7.4