diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-03-07 20:52:48 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-03-07 20:52:48 (GMT) |
commit | c0b4029475158f16f683e4c46a86b28f7a146a1c (patch) | |
tree | a49704dd793189094b3d6cefd90d7f06e6a7cc14 /src/arch/raw.c | |
parent | 12b8a066d1d8dd8cbef587dc6fafed870604f49f (diff) |
Created arrays with low memory footprint.
Diffstat (limited to 'src/arch/raw.c')
-rw-r--r-- | src/arch/raw.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/arch/raw.c b/src/arch/raw.c index f22645f..9d9b8de 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -464,10 +464,12 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s phys_t max_displayed_len; /* Quantité de code affichée */ const char *key; /* Mot clef principal */ size_t klen; /* Taille de ce mot clef */ + size_t count; /* Nombre d'opérandes en place */ char *string; /* Chaîne reconstituée */ size_t iter; /* Tête d'écriture */ bool first; /* Mémorise une énumération */ size_t i; /* Boucle de parcours */ + GArchOperand *op; /* Opérande à manipuler */ char byte; /* Octet à afficher (ou pas) */ bool status; /* Bilan d'une récupération */ @@ -505,18 +507,22 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s else if (instr->is_string) { - string = (char *)calloc(base->operands_count + 3, sizeof(char)); + g_arch_instruction_lock_operands(base); + + count = _g_arch_instruction_count_operands(base); + + string = (char *)calloc(count + 3, sizeof(char)); strcpy(string, "\""); iter = 1; first = true; - g_arch_instruction_lock_operands(base); - - for (i = 0; i < base->operands_count; i++) + for (i = 0; i < count; i++) { - status = g_imm_operand_get_value(G_IMM_OPERAND(base->operands[i]), MDS_8_BITS, &byte); + op = _g_arch_instruction_get_operand(base, i); + + status = g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_8_BITS, &byte); assert(status); /* Si le caractère doit apparaître en hexadécimal... */ @@ -551,7 +557,7 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s else first = false; - g_arch_operand_print(base->operands[i], line, 0/*, syntax*/); + g_arch_operand_print(op, line, 0/*, syntax*/); } @@ -587,16 +593,21 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s { g_arch_instruction_lock_operands(base); - if (base->operands_count > 0) + count = _g_arch_instruction_count_operands(base); + + if (count > 0) { - g_arch_operand_print(base->operands[0], line, 0/*syntax*/); + op = _g_arch_instruction_get_operand(base, 0); + g_arch_operand_print(op, line, 0/*syntax*/); - for (i = 1; i < base->operands_count; i++) + for (i = 1; i < count; i++) { g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); - g_arch_operand_print(base->operands[i], line, 0/*syntax*/); + op = _g_arch_instruction_get_operand(base, i); + + g_arch_operand_print(op, line, 0/*syntax*/); } |