jeyzu pushed a commit to branch master.
commit 380435abdb627159553d8a44d60d0948ba101651
Author: Jérémy Zurcher <[email protected]>
Date: Thu May 16 11:50:21 2013 +0200
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),
--
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d