summaryrefslogtreecommitdiff
path: root/src/arch/raw.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-04-20 18:52:01 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-04-20 18:52:01 (GMT)
commit8e5c8417e8ef79c1b475cb1b86a1754b24f9af78 (patch)
tree650a39bde7a5367995b471a562aa766febd505bc /src/arch/raw.c
parentc177597d6da5dedb32aa176e8370db8ffb7f87aa (diff)
Shared immediate operands in order to avoid useless allocations.
Diffstat (limited to 'src/arch/raw.c')
-rw-r--r--src/arch/raw.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/arch/raw.c b/src/arch/raw.c
index 9d9b8de..b84d9f7 100644
--- a/src/arch/raw.c
+++ b/src/arch/raw.c
@@ -195,17 +195,17 @@ static void g_raw_instruction_finalize(GRawInstruction *instr)
GArchInstruction *g_raw_instruction_new_from_value(const vmpa2t *addr, MemoryDataSize size, uint64_t value)
{
GArchInstruction *result; /* Instruction à retourner */
- GArchOperand *operand; /* Octet non décodé à afficher */
+ GImmOperand *operand; /* Octet non décodé à afficher */
mrange_t range; /* Couverture de l'instruction */
result = g_object_new(G_TYPE_RAW_INSTRUCTION, NULL);
- operand = g_imm_operand_new_from_value(size, value);
+ operand = G_IMM_OPERAND(g_imm_operand_new_from_value(size, value));
if (operand == NULL) goto grinfv_error;
- g_imm_operand_pad(G_IMM_OPERAND(operand), true);
+ g_imm_operand_pad(&operand, true, NULL);
- g_arch_instruction_attach_extra_operand(result, operand);
+ g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand));
switch (size)
{
@@ -348,7 +348,7 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory
GArchInstruction *result; /* Instruction à retourner */
vmpa2t old; /* Sauvegarde de la position */
size_t i; /* Boucle de parcours */
- GArchOperand *operand; /* Octet non décodé à afficher */
+ GImmOperand *operand; /* Octet non décodé à afficher */
mrange_t range; /* Couverture de l'instruction */
/* Par soucis de cohérence */
@@ -360,12 +360,13 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory
for (i = 0; i < count; i++)
{
- operand = g_imm_operand_new_from_data(size, content, addr, endian);
+ operand = G_IMM_OPERAND(g_imm_operand_new_from_data(size, content, addr, endian));
if (operand == NULL) goto grina_error;
- g_imm_operand_pad(G_IMM_OPERAND(operand), true);
+ g_imm_operand_pad(&operand, true, NULL);
+
+ g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand));
- g_arch_instruction_attach_extra_operand(result, operand);
}
init_mrange(&range, &old, compute_vmpa_diff(addr, &old));