diff options
Diffstat (limited to 'src/arch/operand.c')
-rw-r--r-- | src/arch/operand.c | 39 |
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); |