aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2023-01-20 10:16:56 +0100
committerJan Beulich <jbeulich@suse.com>2023-01-20 10:16:56 +0100
commit992dd393c9430ac77df30017f47dc607da69e9a0 (patch)
treeb9b2cc330d0de0056880ee4291ab0773dc2890be /opcodes
parent3e451ee4a654ae2eec22b6f807cf6ad00f7969b9 (diff)
downloadgdb-992dd393c9430ac77df30017f47dc607da69e9a0.zip
gdb-992dd393c9430ac77df30017f47dc607da69e9a0.tar.gz
gdb-992dd393c9430ac77df30017f47dc607da69e9a0.tar.bz2
x86: absorb allocation in i386-gen
When generating the mnemonic string table we already set up an identifier for the following entry in a number of cases. Re-use that on the next loop iteration rather than re-doing allocation and conversion.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/i386-gen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index e3a5012..112e48e 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -1750,13 +1750,15 @@ process_i386_opcodes (FILE *table)
fprintf (table, "const char i386_mnemonics[] =\n");
fprintf (fp, "\nextern const char i386_mnemonics[];\n\n");
+ str = NULL;
for (l = strlen (opcode_array[offs = j = 0]->name); j < i; j++)
{
const char *next = NULL;
size_t l1 = j + 1 < i ? strlen(next = opcode_array[j + 1]->name) : 0;
name = opcode_array[j]->name;
- str = mkident (name);
+ if (str == NULL)
+ str = mkident (name);
if (l < l1 && !strcmp(name, next + l1 - l))
{
fprintf (fp, "#define MN_%s ", str);
@@ -1769,8 +1771,9 @@ process_i386_opcodes (FILE *table)
fprintf (table, " \"\\0\"\"%s\"\n", name);
fprintf (fp, "#define MN_%s %#x\n", str, offs + 1);
offs += strlen (name) + 1;
+ free (str);
+ str = NULL;
}
- free (str);
l = l1;
}