intel/tools: Stop malloc'ing device info in i965_disasm
There's not really any point, a stack allocated struct works fine. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17309>
This commit is contained in:
committed by
Marge Bot
parent
fdae90aa85
commit
c0784804a1
@@ -113,24 +113,6 @@ i965_disasm_read_binary(FILE *fp, size_t *end)
|
||||
return assembly;
|
||||
}
|
||||
|
||||
static struct intel_device_info *
|
||||
i965_disasm_init(uint16_t pci_id)
|
||||
{
|
||||
struct intel_device_info *devinfo;
|
||||
|
||||
devinfo = malloc(sizeof *devinfo);
|
||||
if (devinfo == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!intel_get_device_info_from_pci_id(pci_id, devinfo)) {
|
||||
fprintf(stderr, "can't find device information: pci_id=0x%x\n",
|
||||
pci_id);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return devinfo;
|
||||
}
|
||||
|
||||
static void
|
||||
print_help(const char *progname, FILE *file)
|
||||
{
|
||||
@@ -154,7 +136,6 @@ int main(int argc, char *argv[])
|
||||
size_t start = 0, end = 0;
|
||||
uint16_t pci_id = 0;
|
||||
int c;
|
||||
struct intel_device_info *devinfo = NULL;
|
||||
int result = EXIT_FAILURE;
|
||||
|
||||
bool help = false;
|
||||
@@ -221,11 +202,10 @@ int main(int argc, char *argv[])
|
||||
exit(0);
|
||||
}
|
||||
|
||||
devinfo = i965_disasm_init(pci_id);
|
||||
if (!devinfo) {
|
||||
fprintf(stderr, "Unable to allocate memory for "
|
||||
"intel_device_info struct instance.\n");
|
||||
goto end;
|
||||
struct intel_device_info devinfo;
|
||||
if (!intel_get_device_info_from_pci_id(pci_id, &devinfo)) {
|
||||
fprintf(stderr, "can't find device information: pci_id=0x%x\n", pci_id);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (input_type == OPT_INPUT_BINARY)
|
||||
@@ -243,7 +223,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Disassemble i965 instructions from buffer assembly */
|
||||
brw_disassemble_with_labels(devinfo, assembly, start, end, stdout);
|
||||
brw_disassemble_with_labels(&devinfo, assembly, start, end, stdout);
|
||||
|
||||
result = EXIT_SUCCESS;
|
||||
|
||||
@@ -253,7 +233,6 @@ end:
|
||||
|
||||
free(file_path);
|
||||
free(assembly);
|
||||
free(devinfo);
|
||||
|
||||
exit(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user