summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-03-04 20:52:50 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-03-04 20:52:50 (GMT)
commit27c21356d494824850005932f3dee5f38d7a8e82 (patch)
tree6d7381f9cde78d28b4664f73ef03d0adb5b7b288 /src/analysis
parent72bebbd9dc7d59f69e23442b6c5b5526feb2a1a9 (diff)
Provided access to the graph layout from Python.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/block.c18
-rw-r--r--src/analysis/block.h4
-rw-r--r--src/analysis/disass/dragon.c2
3 files changed, 15 insertions, 9 deletions
diff --git a/src/analysis/block.c b/src/analysis/block.c
index 85c8017..8dd76cf 100644
--- a/src/analysis/block.c
+++ b/src/analysis/block.c
@@ -636,7 +636,10 @@ GBlockList *g_block_list_new(size_t count)
result = g_object_new(G_TYPE_BLOCK_LIST, NULL);
- result->blocks = calloc(count, sizeof(GCodeBlock *));
+ if (count == 0)
+ result->blocks = NULL;
+ else
+ result->blocks = calloc(count, sizeof(GCodeBlock *));
result->count = count;
@@ -696,12 +699,12 @@ void g_block_list_add_block(GBlockList *list, GCodeBlock *block, size_t index)
}
-
/******************************************************************************
* *
-* Paramètres : list = ensemble des blocs de code à traiter. *
+* Paramètres : list = liste de blocs de code à compléter. *
+* block = bloc de code à intégrer. *
* *
-* Description : Etablit les liens entre les blocs de code et leurs voisins. *
+* Description : Ajoute un bloc de code à une liste en construction. *
* *
* Retour : - *
* *
@@ -709,8 +712,13 @@ void g_block_list_add_block(GBlockList *list, GCodeBlock *block, size_t index)
* *
******************************************************************************/
-void g_block_list_resolve_links(const GBlockList *list)
+void g_block_list_append_block(GBlockList *list, GCodeBlock *block)
{
+ list->blocks = realloc(list->blocks, ++list->count * sizeof(GCodeBlock *));
+
+ list->blocks[list->count - 1] = block;
+
+ g_code_block_set_index(block, list->count - 1);
}
diff --git a/src/analysis/block.h b/src/analysis/block.h
index bb3db3e..d2a7b21 100644
--- a/src/analysis/block.h
+++ b/src/analysis/block.h
@@ -142,8 +142,8 @@ size_t g_block_list_count_blocks(const GBlockList *);
/* Ajoute un bloc de code à une liste définie. */
void g_block_list_add_block(GBlockList *, GCodeBlock *, size_t);
-/* Etablit les liens entre les blocs de code et leurs voisins. */
-void g_block_list_resolve_links(const GBlockList *);
+/* Ajoute un bloc de code à une liste en construction. */
+void g_block_list_append_block(GBlockList *, GCodeBlock *);
/* Fournit le bloc de code correspondant à un indice de liste. */
GCodeBlock *g_block_list_get_block(const GBlockList *, size_t);
diff --git a/src/analysis/disass/dragon.c b/src/analysis/disass/dragon.c
index 89dc784..5e8c2d3 100644
--- a/src/analysis/disass/dragon.c
+++ b/src/analysis/disass/dragon.c
@@ -833,8 +833,6 @@ GBlockList *translate_dragon_knight(const dragon_knight *knight, GLoadedBinary *
}
- g_block_list_resolve_links(result);
-
return result;
}