summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-03-05 00:08:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-03-05 00:08:23 (GMT)
commit0320d85e480882c58f254640a54c6c6e190dbf47 (patch)
treed1683e4c6704cb442ff826266e86406759c6a5a8
parent94792f74a850cf6bb119c59ac0675591f4ef6c0f (diff)
Compressed the size of operands with no alternative rendering.
-rw-r--r--ChangeLog6
-rw-r--r--src/arch/operand-int.h15
-rw-r--r--src/arch/operand.c39
3 files changed, 41 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 0c893d8..be4bd7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+17-03-05 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/arch/operand-int.h:
+ * src/arch/operand.c:
+ Compress the size of operands with no alternative rendering.
+
17-03-03 Cyrille Bagard <nocbos@gmail.com>
* src/analysis/db/cdb.c:
diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h
index 6aa15e8..eb1a1d7 100644
--- a/src/arch/operand-int.h
+++ b/src/arch/operand-int.h
@@ -37,16 +37,23 @@ typedef int (* operand_compare_fc) (const GArchOperand * const *, const GArchOpe
typedef void (* operand_print_fc) (const GArchOperand *, GBufferLine *, AsmSyntax);
+/* Adjonction de rendu alternatif */
+typedef struct _alt_rendering
+{
+ RenderingTagType tag; /* Type de rendu */
+ char text[0]; /* Texte alternatif */
+
+} alt_rendering;
+
+
/* Définition générique d'un opérande d'architecture (instance) */
struct _GArchOperand
{
GObject parent; /* A laisser en premier */
- unsigned int shared_count; /* Compteur de partages */
+ alt_rendering *alt_info; /* Autre rendu éventuel */
- char *alt_text; /* Eventuel texte alternatif */
- size_t alt_len; /* Taille de ce texte */
- RenderingTagType alt_tag; /* Type de rendu */
+ unsigned int shared_count; /* Compteur de partages */
};
diff --git a/src/arch/operand.c b/src/arch/operand.c
index dc0559a..731c757 100644
--- a/src/arch/operand.c
+++ b/src/arch/operand.c
@@ -333,20 +333,23 @@ int g_arch_operand_compare(const GArchOperand * const *a, const GArchOperand * c
void g_arch_operand_set_alt_text(GArchOperand *operand, const char *text, RenderingTagType tag)
{
- if (operand->alt_text != NULL)
- free(operand->alt_text);
+ size_t alt_len; /* Taille du texte alternatif */
+
+ if (operand->alt_info != NULL)
+ free(operand->alt_info);
+
+ if (text == NULL)
+ operand->alt_info = NULL;
- if (text != NULL)
- {
- operand->alt_text = strdup(text);
- operand->alt_len = strlen(text);
- operand->alt_tag = tag;
- }
else
{
- operand->alt_text = NULL;
- operand->alt_len = 0;
- operand->alt_tag = RTT_COUNT;
+ alt_len = strlen(text);
+
+ operand->alt_info = (alt_rendering *)malloc(sizeof(RenderingTagType) + alt_len + 1);
+
+ operand->alt_info->tag = tag;
+ strcpy(operand->alt_info->text, text);
+
}
}
@@ -368,13 +371,19 @@ void g_arch_operand_set_alt_text(GArchOperand *operand, const char *text, Render
void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line, AsmSyntax syntax)
{
- if (operand->alt_text != NULL)
+ size_t alt_len; /* Taille du texte alternatif */
+
+ if (operand->alt_info != NULL)
+ {
+ alt_len = strlen(operand->alt_info->text);
+
g_buffer_line_append_text(line, BLC_ASSEMBLY,
- operand->alt_text,
- operand->alt_len,
- operand->alt_tag,
+ operand->alt_info->text,
+ alt_len,
+ operand->alt_info->tag,
NULL);
+ }
else
G_ARCH_OPERAND_GET_CLASS(operand)->print(operand, line, syntax);