Commit 9739b11a authored by Paolo Bonzini's avatar Paolo Bonzini

cris: do not leak struct cris_disasm_data

Use a stack-allocated struct to avoid a memory leak.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 0287d89f
......@@ -1294,24 +1294,17 @@ static int cris_constraint
/* Parse disassembler options and store state in info. FIXME: For the
time being, we abuse static variables. */
static bfd_boolean
cris_parse_disassembler_options (disassemble_info *info,
static void
cris_parse_disassembler_options (struct cris_disasm_data *disdata,
char *disassembler_options,
enum cris_disass_family distype)
{
struct cris_disasm_data *disdata;
info->private_data = calloc (1, sizeof (struct cris_disasm_data));
disdata = (struct cris_disasm_data *) info->private_data;
if (disdata == NULL)
return false;
/* Default true. */
disdata->trace_case
= (info->disassembler_options == NULL
|| (strcmp (info->disassembler_options, "nocase") != 0));
= (disassembler_options == NULL
|| (strcmp (disassembler_options, "nocase") != 0));
disdata->distype = distype;
return true;
}
static const struct cris_spec_reg *
......@@ -2736,9 +2729,10 @@ static int
print_insn_cris_with_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
return -1;
struct cris_disasm_data disdata;
info->private_data = &disdata;
cris_parse_disassembler_options (&disdata, info->disassembler_options,
cris_dis_v0_v10);
return print_insn_cris_generic (vma, info, true);
}
/* Disassemble, prefixing register names with `$'. CRIS v32. */
......@@ -2747,9 +2741,10 @@ static int
print_insn_crisv32_with_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v32))
return -1;
struct cris_disasm_data disdata;
info->private_data = &disdata;
cris_parse_disassembler_options (&disdata, info->disassembler_options,
cris_dis_v32);
return print_insn_cris_generic (vma, info, true);
}
......@@ -2761,9 +2756,10 @@ static int
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
return -1;
struct cris_disasm_data disdata;
info->private_data = &disdata;
cris_parse_disassembler_options (&disdata, info->disassembler_options,
cris_dis_common_v10_v32);
return print_insn_cris_generic (vma, info, true);
}
......@@ -2773,9 +2769,10 @@ static int
print_insn_cris_without_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
return -1;
struct cris_disasm_data disdata;
info->private_data = &disdata;
cris_parse_disassembler_options (&disdata, info->disassembler_options,
cris_dis_v0_v10);
return print_insn_cris_generic (vma, info, false);
}
......@@ -2785,9 +2782,10 @@ static int
print_insn_crisv32_without_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_v32))
return -1;
struct cris_disasm_data disdata;
info->private_data = &disdata;
cris_parse_disassembler_options (&disdata, info->disassembler_options,
cris_dis_v32);
return print_insn_cris_generic (vma, info, false);
}
......@@ -2798,9 +2796,10 @@ static int
print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
return -1;
struct cris_disasm_data disdata;
info->private_data = &disdata;
cris_parse_disassembler_options (&disdata, info->disassembler_options,
cris_dis_common_v10_v32);
return print_insn_cris_generic (vma, info, false);
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment