mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 00:05:36 +00:00
machine: use class base init generated name
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
This commit is contained in:
parent
8648b1df4f
commit
aee9f7327f
|
@ -26,6 +26,13 @@ static void machine_class_base_init(struct uc_struct *uc, ObjectClass *oc, void
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
@ -50,7 +57,7 @@ static const TypeInfo machine_info = {
|
|||
|
||||
NULL,
|
||||
machine_class_base_init,
|
||||
NULL,
|
||||
machine_class_finalize,
|
||||
|
||||
true,
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ struct MachineClass {
|
|||
ObjectClass parent_class;
|
||||
/*< public >*/
|
||||
|
||||
const char *name;
|
||||
char *name;
|
||||
|
||||
int (*init)(struct uc_struct *uc, MachineState *state);
|
||||
void (*reset)(void);
|
||||
|
|
|
@ -54,14 +54,20 @@ void x86_cpu_register_types(struct uc_struct *uc);
|
|||
MachineClass *mc = MACHINE_CLASS(uc, oc); \
|
||||
mc->max_cpus = 255; \
|
||||
mc->is_default = 1; \
|
||||
mc->name = namestr; \
|
||||
mc->init = initfn; \
|
||||
mc->arch = UC_ARCH_X86; \
|
||||
} \
|
||||
static const TypeInfo pc_machine_type_##suffix = { \
|
||||
.name = namestr TYPE_MACHINE_SUFFIX, \
|
||||
.parent = TYPE_PC_MACHINE, \
|
||||
.class_init = pc_machine_##suffix##_class_init, \
|
||||
namestr TYPE_MACHINE_SUFFIX, \
|
||||
TYPE_PC_MACHINE, \
|
||||
0, \
|
||||
0, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
pc_machine_##suffix##_class_init, \
|
||||
}; \
|
||||
void pc_machine_init_##suffix(struct uc_struct *uc); \
|
||||
void pc_machine_init_##suffix(struct uc_struct *uc) \
|
||||
|
|
Loading…
Reference in a new issue