summaryrefslogtreecommitdiff
path: root/src/analysis/scan/matches/pending.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/scan/matches/pending.c')
-rw-r--r--src/analysis/scan/matches/pending.c147
1 files changed, 133 insertions, 14 deletions
diff --git a/src/analysis/scan/matches/pending.c b/src/analysis/scan/matches/pending.c
index 9ed4de3..c653257 100644
--- a/src/analysis/scan/matches/pending.c
+++ b/src/analysis/scan/matches/pending.c
@@ -33,6 +33,8 @@
+
+
/* ------------------------- MEMORISATION D'UNE ZONE BORNEE ------------------------- */
@@ -50,8 +52,6 @@ static int compare_match_area(const match_area_t *, const match_area_t *);
-
-
/* ---------------------------------------------------------------------------------- */
/* MEMORISATION D'UNE ZONE BORNEE */
/* ---------------------------------------------------------------------------------- */
@@ -59,6 +59,104 @@ static int compare_match_area(const match_area_t *, const match_area_t *);
/******************************************************************************
* *
+* Paramètres : allocator = allocateur dédié à l'ensemble de zones. *
+* start = point de départ d'une nouvelle correspondance. *
+* length = taille de la zone couverte. *
+* *
+* Description : Crée une nouvelle structure de suivi de correspondance. *
+* *
+* Retour : Structure initialisée mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static match_area_t *create_match_area(GUMemCache *allocator, phys_t start, phys_t length)
+{
+ match_area_t *result; /* Zone à retourner */
+
+ result = g_umem_cache_alloc(allocator);
+
+ DL_LIST_ITEM_INIT(&result->link);
+
+ result->start = start;
+ result->end = start + length;
+
+ assert(matches->content_start <= result->start);
+ assert(result->end <= matches->content_end);
+
+ result->ttl = 1;
+
+ result->has_mod_path = false;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : allocator = allocateur dédié à l'ensemble de zones. *
+* start = point de départ d'une nouvelle correspondance. *
+* length = taille de la zone couverte. *
+* index = indice de construction pour le motif concerné. *
+* *
+* Description : Crée une nouvelle structure de suivi de correspondance. *
+* *
+* Retour : Structure initialisée mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static match_area_t *create_match_area_with_path(GUMemCache *allocator, phys_t start, phys_t length, size_t index)
+{
+ match_area_t *result; /* Zone à retourner */
+
+ result = g_umem_cache_alloc(allocator);
+
+ DL_LIST_ITEM_INIT(&result->link);
+
+ result->start = start;
+ result->end = start + length;
+
+ assert(matches->content_start <= result->start);
+ assert(result->end <= matches->content_end);
+
+ result->ttl = 1;
+
+ result->mod_path_index = index;
+ result->has_mod_path = true;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : area = zone de suivi à supprimer. *
+* allocator = allocateur dédié à l'ensemble de zones. *
+* *
+* Description : Supprime une structure de suivi de correspondance. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void delete_match_area(match_area_t *area, GUMemCache *allocator)
+{
+ // TODO : assert(alone)
+
+ g_umem_cache_free(allocator, area);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : a = pointeur vers la première zone à analyser. *
* b = pointeur vers la seconde zone à analyser. *
* *
@@ -82,6 +180,12 @@ static int compare_match_area(const match_area_t *a, const match_area_t *b)
if (result == 0)
result = sort_unsigned_long_long(a->ttl, b->ttl);
+ if (result == 0)
+ result = sort_unsigned_long_long(a->has_mod_path, b->has_mod_path);
+
+ if (result == 0)
+ result = sort_unsigned_long_long(a->mod_path_index, b->mod_path_index);
+
return result;
}
@@ -112,6 +216,7 @@ void init_pending_matches(pending_matches_t *matches, const phys_t *start, const
matches->content_start = *start;
matches->content_end = *end;
+ matches->allocator = NULL;
matches->areas = NULL;
matches->allocated = 0;
matches->used = 0;
@@ -273,25 +378,39 @@ match_area_t * const *get_all_pending_matches(const pending_matches_t *matches,
void add_pending_match(pending_matches_t *matches, phys_t start, phys_t length)
{
- match_area_t *area; /* Zone à initialiser */
+ match_area_t *area; /* Nouvelle zone à intégrer */
- if (matches->used == matches->allocated)
- {
- matches->allocated += PENDING_ALLOC_SIZE;
+ area = create_match_area(matches->allocator, start, length);
- matches->areas = realloc(matches->areas, matches->allocated * sizeof(match_area_t));
+ dl_list_add_tail(area, &matches->areas, match_area_t, link);
+ matches->used++;
- }
+}
- area = &matches->areas[matches->used++];
- area->start = start;
- area->end = start + length;
+/******************************************************************************
+* *
+* Paramètres : matches = suivi de correspondances à compléter. *
+* start = point de départ d'une nouvelle correspondance. *
+* length = taille de la zone couverte. *
+* index = indice de construction pour le motif concerné. *
+* *
+* Description : Ajoute au suivi la définition d'une nouvelle correspondance. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void add_pending_match_with_path(pending_matches_t *matches, phys_t start, phys_t length, size_t index)
+{
+ match_area_t *area; /* Nouvelle zone à intégrer */
- assert(matches->content_start <= area->start);
- assert(area->end <= matches->content_end);
+ area = create_match_area_with_path(matches->allocator, start, length, index);
- area->ttl = 1;
+ dl_list_add_tail(area, &matches->areas, match_area_t, link);
+ matches->used++;
}