summaryrefslogtreecommitdiff
path: root/src/arch/operand.c
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 /src/arch/operand.c
parent94792f74a850cf6bb119c59ac0675591f4ef6c0f (diff)
Compressed the size of operands with no alternative rendering.
Diffstat (limited to 'src/arch/operand.c')
-rw-r--r--src/arch/operand.c39
1 files changed, 24 insertions, 15 deletions
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);