mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-26 13:05:29 +00:00
aee9f7327f
machine_class_base_init() member name is allocated by machine_class_base_init(), but not freed by machine_class_finalize(). Simply freeing there doesn't work, because DEFINE_PC_MACHINE() overwrites it with a literal string. Fix DEFINE_PC_MACHINE() not to overwrite it, and add the missing free to machine_class_finalize(). Backports commit 8ea753718b2d1a42e9ce7b8db9f5e4e1f330e827 from qemu
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
/*
|
|
* QEMU Machine
|
|
*
|
|
* Copyright (C) 2014 Red Hat Inc
|
|
*
|
|
* Authors:
|
|
* Marcel Apfelbaum <marcel.a@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "hw/boards.h"
|
|
#include "qapi/error.h"
|
|
#include "qemu/cutils.h"
|
|
|
|
static void machine_class_base_init(struct uc_struct *uc, ObjectClass *oc, void *data)
|
|
{
|
|
if (!object_class_is_abstract(oc)) {
|
|
MachineClass *mc = MACHINE_CLASS(uc, oc);
|
|
const char *cname = object_class_get_name(oc);
|
|
assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
|
|
mc->name = g_strndup(cname,
|
|
strlen(cname) - strlen(TYPE_MACHINE_SUFFIX));
|
|
}
|
|
}
|
|
|
|
static void machine_class_finalize(struct uc_struct *uc, ObjectClass *klass, void *data)
|
|
{
|
|
MachineClass *mc = MACHINE_CLASS(uc, klass);
|
|
|
|
g_free(mc->name);
|
|
}
|
|
|
|
static void machine_initfn(struct uc_struct *uc, Object *obj, void *opaque)
|
|
{
|
|
}
|
|
|
|
static void machine_finalize(struct uc_struct *uc, Object *obj, void *opaque)
|
|
{
|
|
}
|
|
|
|
static const TypeInfo machine_info = {
|
|
TYPE_MACHINE,
|
|
TYPE_OBJECT,
|
|
|
|
sizeof(MachineClass),
|
|
sizeof(MachineState),
|
|
NULL,
|
|
|
|
machine_initfn,
|
|
NULL,
|
|
machine_finalize,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
machine_class_base_init,
|
|
machine_class_finalize,
|
|
|
|
true,
|
|
};
|
|
|
|
void machine_register_types(struct uc_struct *uc)
|
|
{
|
|
type_register_static(uc, &machine_info);
|
|
}
|