revert to use of g_free to make future qemu integrations easier (#695)

* revert to use of g_free to make future qemu integrations easier

* bracing
This commit is contained in:
Chris Eagle 2016-12-21 06:28:36 -08:00 committed by Nguyen Anh Quynh
parent 6a2eb14ff3
commit fccbcfd4c2
48 changed files with 224 additions and 219 deletions

View File

@ -101,7 +101,7 @@ static AccelClass *accel_find(struct uc_struct *uc, const char *opt_name)
{
char *class_name = g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name);
AccelClass *ac = ACCEL_CLASS(uc, object_class_by_name(uc, class_name));
free(class_name);
g_free(class_name);
return ac;
}

View File

@ -108,7 +108,7 @@ static void *qemu_tcg_cpu_loop(struct uc_struct *uc)
cpu->created = false;
qemu_cond_destroy(cpu->halt_cond);
free(cpu->halt_cond);
g_free(cpu->halt_cond);
cpu->halt_cond = NULL;
qemu_mutex_unlock(&uc->qemu_global_mutex);

View File

@ -517,7 +517,7 @@ void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint)
tlb_flush_page(cpu, watchpoint->vaddr);
free(watchpoint);
g_free(watchpoint);
}
/* Remove all matching watchpoints. */
@ -610,7 +610,7 @@ void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint)
breakpoint_invalidate(cpu, breakpoint->pc);
free(breakpoint);
g_free(breakpoint);
#endif
}
@ -814,7 +814,7 @@ static void phys_section_destroy(MemoryRegion *mr)
if (mr->subpage) {
subpage_t *subpage = container_of(mr, subpage_t, iomem);
object_unref(mr->uc, OBJECT(&subpage->iomem));
free(subpage);
g_free(subpage);
}
}
@ -824,8 +824,8 @@ static void phys_sections_free(PhysPageMap *map)
MemoryRegionSection *section = &map->sections[--map->sections_nb];
phys_section_destroy(section->mr);
}
free(map->sections);
free(map->nodes);
g_free(map->sections);
g_free(map->nodes);
}
static void register_subpage(struct uc_struct* uc,
@ -1086,7 +1086,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
}
addr = ram_block_add(mr->uc, new_block, &local_err);
if (local_err) {
free(new_block);
g_free(new_block);
error_propagate(errp, local_err);
return -1;
}
@ -1109,7 +1109,7 @@ void qemu_ram_free_from_ptr(struct uc_struct *uc, ram_addr_t addr)
QTAILQ_REMOVE(&uc->ram_list.blocks, block, next);
uc->ram_list.mru_block = NULL;
uc->ram_list.version++;
free(block);
g_free(block);
break;
}
}
@ -1137,7 +1137,7 @@ void qemu_ram_free(struct uc_struct *uc, ram_addr_t addr)
} else {
qemu_anon_ram_free(block->host, block->length);
}
free(block);
g_free(block);
break;
}
}
@ -1457,7 +1457,7 @@ MemoryRegion *iotlb_to_region(AddressSpace *as, hwaddr index)
void phys_mem_clean(struct uc_struct* uc)
{
AddressSpaceDispatch* d = uc->as.next_dispatch;
free(d->map.sections);
g_free(d->map.sections);
}
static void mem_begin(MemoryListener *listener)
@ -1494,7 +1494,7 @@ static void mem_commit(MemoryListener *listener)
if (cur) {
phys_sections_free(&cur->map);
free(cur);
g_free(cur);
}
}
@ -1531,13 +1531,13 @@ void address_space_destroy_dispatch(AddressSpace *as)
AddressSpaceDispatch *d = as->dispatch;
memory_listener_unregister(as->uc, &as->dispatch_listener);
free(d->map.nodes);
free(d);
g_free(d->map.nodes);
g_free(d);
if (as->dispatch != as->next_dispatch) {
d = as->next_dispatch;
free(d->map.nodes);
free(d);
g_free(d->map.nodes);
g_free(d);
}
as->dispatch = NULL;

View File

@ -561,6 +561,11 @@ guint g_hash_table_size(GHashTable *hash_table)
/* general g_XXX substitutes */
void g_free(void *ptr)
{
free(ptr);
}
void *g_malloc(size_t size)
{
if (size == 0) return NULL;

View File

@ -176,7 +176,7 @@ static int device_set_realized(struct uc_struct *uc, Object *obj, bool value, Er
object_property_add_child(container_get(qdev_get_machine(),
"/unattached"),
name, obj, &error_abort);
free(name);
g_free(name);
}
#endif
@ -305,7 +305,7 @@ static void qbus_finalize(struct uc_struct *uc, Object *obj, void *opaque)
{
BusState *bus = BUS(uc, obj);
free((char *)bus->name);
g_free((char *)bus->name);
}
static const TypeInfo bus_info = {

View File

@ -745,7 +745,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
if (ret < 0 || ret > PROM_SIZE_MAX) {
ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
}
free(filename);
g_free(filename);
} else {
ret = -1;
}

View File

@ -106,7 +106,7 @@ GHashTable *g_hash_table_ref(GHashTable *hash_table);
guint g_hash_table_size(GHashTable *hash_table);
/* replacement for g_malloc dependency */
#define g_free(x) free(x)
void g_free(void *ptr);
void *g_malloc(size_t size);
void *g_malloc0(size_t size);
void *g_try_malloc0(size_t size);

View File

@ -57,7 +57,7 @@ struct arm_boot_info {
* sets get_dtb. This will only be used if no dtb file is provided
* by the user. On success, sets *size to the length of the created
* dtb, and returns a pointer to it. (The caller must free this memory
* with free() when it has finished with it.) On failure, returns NULL.
* with g_free() when it has finished with it.) On failure, returns NULL.
*/
void *(*get_dtb)(const struct arm_boot_info *info, int *size);
/* if a board needs to be able to modify a device tree provided by

View File

@ -210,7 +210,7 @@ void fips_set_state(bool requested);
bool fips_get_state(void);
/* Get the saved exec dir.
* Caller needs to release the returned string by free() */
* Caller needs to release the returned string by g_free() */
char *qemu_get_exec_dir(void);
/**

View File

@ -1125,7 +1125,7 @@ void object_property_add_link(Object *obj, const char *name,
* @obj: the object to add a property to
* @name: the name of the property
* @get: the getter or NULL if the property is write-only. This function must
* return a string to be freed by free().
* return a string to be freed by g_free().
* @set: the setter or NULL if the property is read-only
* @errp: if an error occurs, a pointer to an area to store the error
*

View File

@ -91,9 +91,9 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
mr->destructor(mr);
obj = OBJECT(mr);
obj->ref = 1;
obj->free = free;
free(mr->ioeventfds);
free((char *)mr->name);
obj->free = g_free;
g_free(mr->ioeventfds);
g_free((char *)mr->name);
mr->name = NULL;
object_property_del_child(mr->uc, qdev_get_machine(mr->uc), obj, &error_abort);
break;
@ -114,8 +114,8 @@ int memory_free(struct uc_struct *uc)
mr->destructor(mr);
obj = OBJECT(mr);
obj->ref = 1;
obj->free = free;
free(mr->ioeventfds);
obj->free = g_free;
g_free(mr->ioeventfds);
object_property_del_child(mr->uc, qdev_get_machine(mr->uc), obj, &error_abort);
}
@ -375,8 +375,8 @@ static void flatview_destroy(FlatView *view)
for (i = 0; i < view->nr; i++) {
memory_region_unref(view->ranges[i].mr);
}
free(view->ranges);
free(view);
g_free(view->ranges);
g_free(view);
}
static void flatview_ref(FlatView *view)
@ -767,7 +767,7 @@ static void address_space_update_ioeventfds(AddressSpace *as)
address_space_add_del_ioeventfds(as, ioeventfds, ioeventfd_nb,
as->ioeventfds, as->ioeventfd_nb);
free(as->ioeventfds);
g_free(as->ioeventfds);
as->ioeventfds = ioeventfds;
as->ioeventfd_nb = ioeventfd_nb;
flatview_unref(view);
@ -973,8 +973,8 @@ void memory_region_init(struct uc_struct *uc, MemoryRegion *mr,
char *name_array = g_strdup_printf("%s[*]", escaped_name);
object_property_add_child(owner, name_array, OBJECT(mr), &error_abort);
object_unref(uc, OBJECT(mr));
free(name_array);
free(escaped_name);
g_free(name_array);
g_free(escaped_name);
}
}
@ -998,7 +998,7 @@ static void memory_region_get_container(struct uc_struct *uc, Object *obj, Visit
}
visit_type_str(v, &path, name, errp);
if (mr->container) {
free(path);
g_free(path);
}
}
@ -1283,8 +1283,8 @@ static void memory_region_finalize(struct uc_struct *uc, Object *obj, void *opaq
// assert(memory_region_transaction_depth == 0);
mr->destructor(mr);
memory_region_clear_coalescing(mr);
free((char *)mr->name);
free(mr->ioeventfds);
g_free((char *)mr->name);
g_free(mr->ioeventfds);
}
void memory_region_ref(MemoryRegion *mr)
@ -1482,7 +1482,7 @@ void memory_region_clear_coalescing(MemoryRegion *mr)
while (!QTAILQ_EMPTY(&mr->coalesced)) {
cmr = QTAILQ_FIRST(&mr->coalesced);
QTAILQ_REMOVE(&mr->coalesced, cmr, link);
free(cmr);
g_free(cmr);
updated = true;
}
@ -1883,8 +1883,8 @@ void address_space_destroy(AddressSpace *as)
}
flatview_unref(as->current_map);
free(as->name);
free(as->ioeventfds);
g_free(as->name);
g_free(as->ioeventfds);
}
bool io_mem_read(MemoryRegion *mr, hwaddr addr, uint64_t *pval, unsigned size)

View File

@ -161,7 +161,7 @@ void memory_mapping_list_free(MemoryMappingList *list)
QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
QTAILQ_REMOVE(&list->head, p, next);
free(p);
g_free(p);
}
list->num = 0;
@ -181,7 +181,7 @@ void guest_phys_blocks_free(GuestPhysBlockList *list)
QTAILQ_FOREACH_SAFE(p, &list->head, next, q) {
QTAILQ_REMOVE(&list->head, p, next);
free(p);
g_free(p);
}
list->num = 0;
}

View File

@ -55,7 +55,7 @@ static void *qapi_dealloc_pop(QapiDeallocVisitor *qov)
QObject *value;
QTAILQ_REMOVE(&qov->stack, e, node);
value = e->value;
free(e);
g_free(e);
return value;
}
@ -72,7 +72,7 @@ static void qapi_dealloc_end_struct(Visitor *v, Error **errp)
QapiDeallocVisitor *qov = to_qov(v);
void **obj = qapi_dealloc_pop(qov);
if (obj) {
free(*obj);
g_free(*obj);
}
}
@ -90,7 +90,7 @@ static void qapi_dealloc_end_implicit_struct(Visitor *v, Error **errp)
QapiDeallocVisitor *qov = to_qov(v);
void **obj = qapi_dealloc_pop(qov);
if (obj) {
free(*obj);
g_free(*obj);
}
}
@ -114,7 +114,7 @@ static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **listp,
if (list) {
list = list->next;
free(*listp);
g_free(*listp);
return list;
}
@ -132,7 +132,7 @@ static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,
Error **errp)
{
if (obj) {
free(*obj);
g_free(*obj);
}
}
@ -194,7 +194,7 @@ Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
void qapi_dealloc_visitor_cleanup(QapiDeallocVisitor *v)
{
free(v);
g_free(v);
}
QapiDeallocVisitor *qapi_dealloc_visitor_new(void)

View File

@ -304,10 +304,10 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[],
if (strings[value] == NULL) {
error_set(errp, QERR_INVALID_PARAMETER, enum_str);
free(enum_str);
g_free(enum_str);
return;
}
free(enum_str);
g_free(enum_str);
*obj = value;
}

View File

@ -308,7 +308,7 @@ Visitor *qmp_input_get_visitor(QmpInputVisitor *v)
void qmp_input_visitor_cleanup(QmpInputVisitor *v)
{
qobject_decref(v->stack[0].obj);
free(v);
g_free(v);
}
QmpInputVisitor *qmp_input_visitor_new(QObject *obj)

View File

@ -59,7 +59,7 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov)
QObject *value;
QTAILQ_REMOVE(&qov->stack, e, node);
value = e->value;
free(e);
g_free(e);
return value;
}
@ -211,11 +211,11 @@ void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
QTAILQ_REMOVE(&v->stack, e, node);
free(e);
g_free(e);
}
qobject_decref(root);
free(v);
g_free(v);
}
QmpOutputVisitor *qmp_output_visitor_new(void)

View File

@ -34,7 +34,7 @@ struct StringInputVisitor
static void free_range(void *range, void *dummy)
{
free(range);
g_free(range);
}
static void parse_str(StringInputVisitor *siv, Error **errp)
@ -321,7 +321,7 @@ void string_input_visitor_cleanup(StringInputVisitor *v)
{
g_list_foreach(v->ranges, free_range, NULL);
g_list_free(v->ranges);
free(v);
g_free(v);
}
StringInputVisitor *string_input_visitor_new(const char *str)

View File

@ -103,7 +103,7 @@ void timerlist_free(QEMUTimerList *timer_list)
QLIST_REMOVE(timer_list, list);
}
qemu_mutex_destroy(&timer_list->active_timers_lock);
free(timer_list);
g_free(timer_list);
}
bool timerlist_has_timers(QEMUTimerList *timer_list)

View File

@ -354,8 +354,8 @@ static void parser_context_free(JSONParserContext *ctxt)
for (i = 0; i < ctxt->tokens.count; i++) {
qobject_decref(ctxt->tokens.buf[i]);
}
free(ctxt->tokens.buf);
free(ctxt);
g_free(ctxt->tokens.buf);
g_free(ctxt);
}
}

View File

@ -64,5 +64,5 @@ QBool *qobject_to_qbool(const QObject *obj)
static void qbool_destroy_obj(QObject *obj)
{
assert(obj != NULL);
free(qobject_to_qbool(obj));
g_free(qobject_to_qbool(obj));
}

View File

@ -432,8 +432,8 @@ static void qentry_destroy(QDictEntry *e)
assert(e->value != NULL);
qobject_decref(e->value);
free(e->key);
free(e);
g_free(e->key);
g_free(e);
}
/**
@ -474,7 +474,7 @@ static void qdict_destroy_obj(QObject *obj)
}
}
free(qdict);
g_free(qdict);
}
static void qdict_flatten_qdict(QDict *qdict, QDict *target,
@ -509,7 +509,7 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix)
qdict_put_obj(target, new_key, value);
}
free(new_key);
g_free(new_key);
}
}
@ -550,7 +550,7 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix)
delete = true;
}
free(new_key);
g_free(new_key);
if (delete) {
qdict_del(qdict, entry->key);

View File

@ -64,5 +64,5 @@ QFloat *qobject_to_qfloat(const QObject *obj)
static void qfloat_destroy_obj(QObject *obj)
{
assert(obj != NULL);
free(qobject_to_qfloat(obj));
g_free(qobject_to_qfloat(obj));
}

View File

@ -63,5 +63,5 @@ QInt *qobject_to_qint(const QObject *obj)
static void qint_destroy_obj(QObject *obj)
{
assert(obj != NULL);
free(qobject_to_qint(obj));
g_free(qobject_to_qint(obj));
}

View File

@ -98,7 +98,7 @@ QObject *qlist_pop(QList *qlist)
QTAILQ_REMOVE(&qlist->head, entry, next);
ret = entry->value;
free(entry);
g_free(entry);
return ret;
}
@ -163,8 +163,8 @@ static void qlist_destroy_obj(QObject *obj)
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
free(entry);
g_free(entry);
}
free(qlist);
g_free(qlist);
}

View File

@ -144,6 +144,6 @@ static void qstring_destroy_obj(QObject *obj)
assert(obj != NULL);
qs = qobject_to_qstring(obj);
free(qs->string);
free(qs);
g_free(qs->string);
g_free(qs);
}

View File

@ -46,7 +46,7 @@ CPUState *cpu_generic_init(struct uc_struct *uc, const char *typename, const cha
oc = cpu_class_by_name(uc, typename, name);
if (oc == NULL) {
free(str);
g_free(str);
return NULL;
}
@ -55,7 +55,7 @@ CPUState *cpu_generic_init(struct uc_struct *uc, const char *typename, const cha
featurestr = strtok(NULL, ",");
cc->parse_features(cpu, featurestr, &err);
free(str);
g_free(str);
if (err != NULL) {
goto out;
}

View File

@ -227,7 +227,7 @@ static void type_initialize_interface(struct uc_struct *uc, TypeImpl *ti, TypeIm
iface_impl = type_new(uc, &info);
iface_impl->parent_type = parent_type;
type_initialize(uc, iface_impl);
free((char *)info.name);
g_free((char *)info.name);
new_iface = (InterfaceClass *)iface_impl->class;
new_iface->concrete_class = ti->class;
@ -363,10 +363,10 @@ static void object_property_del_all(struct uc_struct *uc, Object *obj)
prop->release(uc, obj, prop->name, prop->opaque);
}
free(prop->name);
free(prop->type);
free(prop->description);
free(prop);
g_free(prop->name);
g_free(prop->type);
g_free(prop->description);
g_free(prop);
}
}
@ -423,7 +423,7 @@ static Object *object_new_with_type(struct uc_struct *uc, Type type)
obj = g_malloc(type->instance_size);
object_initialize_with_type(uc, obj, type->instance_size, type);
obj->free = free;
obj->free = g_free;
return obj;
}
@ -733,12 +733,12 @@ object_property_add(Object *obj, const char *name, const char *type,
ret = object_property_add(obj, full_name, type, get, set,
release, opaque, NULL);
free(full_name);
g_free(full_name);
if (ret) {
break;
}
}
free(name_no_array);
g_free(name_no_array);
return ret;
}
@ -793,10 +793,10 @@ void object_property_del(struct uc_struct *uc, Object *obj, const char *name, Er
QTAILQ_REMOVE(&obj->properties, prop, node);
free(prop->name);
free(prop->type);
free(prop->description);
free(prop);
g_free(prop->name);
g_free(prop->type);
g_free(prop->description);
g_free(prop);
}
void object_property_get(struct uc_struct *uc, Object *obj, Visitor *v, const char *name,
@ -867,7 +867,7 @@ void object_property_set_link(struct uc_struct *uc, Object *obj, Object *value,
if (value) {
gchar *path = object_get_canonical_path(value);
object_property_set_str(uc, obj, path, name, errp);
free(path);
g_free(path);
} else {
object_property_set_str(uc, obj, "", name, errp);
}
@ -886,7 +886,7 @@ Object *object_property_get_link(struct uc_struct *uc, Object *obj, const char *
}
}
free(str);
g_free(str);
return target;
}
@ -989,7 +989,7 @@ static void object_get_child_property(struct uc_struct *uc, Object *obj, Visitor
path = object_get_canonical_path(child);
visit_type_str(v, &path, name, errp);
free(path);
g_free(path);
}
static Object *object_resolve_child_property(struct uc_struct *uc, Object *parent, void *opaque, const gchar *part)
@ -1035,7 +1035,7 @@ void object_property_add_child(Object *obj, const char *name,
child->parent = obj;
out:
free(type);
g_free(type);
}
void object_property_allow_set_link(Object *obj, const char *name,
@ -1060,7 +1060,7 @@ static void object_get_link_property(struct uc_struct *uc, Object *obj, Visitor
if (*child) {
path = object_get_canonical_path(*child);
visit_type_str(v, &path, name, errp);
free(path);
g_free(path);
} else {
path = (gchar *)"";
visit_type_str(v, &path, name, errp);
@ -1101,7 +1101,7 @@ static Object *object_resolve_link(struct uc_struct *uc, Object *obj, const char
}
target = NULL;
}
free(target_type);
g_free(target_type);
return target;
}
@ -1122,7 +1122,7 @@ static int object_set_link_property(struct uc_struct *uc, Object *obj, Visitor *
new_target = object_resolve_link(uc, obj, name, path, &local_err);
}
free(path);
g_free(path);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@ -1156,7 +1156,7 @@ static void object_release_link_property(struct uc_struct *uc, Object *obj, cons
if ((prop->flags & OBJ_PROP_LINK_UNREF_ON_RELEASE) && *prop->child) {
object_unref(uc, *prop->child);
}
free(prop);
g_free(prop);
}
void object_property_add_link(Object *obj, const char *name,
@ -1185,14 +1185,14 @@ void object_property_add_link(Object *obj, const char *name,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
free(prop);
g_free(prop);
goto out;
}
op->resolve = object_resolve_link_property;
out:
free(full_type);
g_free(full_type);
}
gchar *object_get_canonical_path_component(Object *obj)
@ -1227,8 +1227,8 @@ gchar *object_get_canonical_path(Object *obj)
if (path) {
newpath = g_strdup_printf("%s/%s", component, path);
free(component);
free(path);
g_free(component);
g_free(path);
path = newpath;
} else {
path = component;
@ -1238,7 +1238,7 @@ gchar *object_get_canonical_path(Object *obj)
}
newpath = g_strdup_printf("/%s", path ? path : "");
free(path);
g_free(path);
return newpath;
}
@ -1361,7 +1361,7 @@ static void property_get_str(struct uc_struct *uc, Object *obj, Visitor *v, void
value = prop->get(uc, obj, errp);
if (value) {
visit_type_str(v, &value, name, errp);
free(value);
g_free(value);
}
}
@ -1379,7 +1379,7 @@ static int property_set_str(struct uc_struct *uc, Object *obj, Visitor *v, void
}
prop->set(uc, obj, value, errp);
free(value);
g_free(value);
return 0;
}
@ -1388,7 +1388,7 @@ static void property_release_str(struct uc_struct *uc, Object *obj, const char *
void *opaque)
{
StringProperty *prop = opaque;
free(prop);
g_free(prop);
}
void object_property_add_str(Object *obj, const char *name,
@ -1409,7 +1409,7 @@ void object_property_add_str(Object *obj, const char *name,
prop, &local_err);
if (local_err) {
error_propagate(errp, local_err);
free(prop);
g_free(prop);
}
}
@ -1449,7 +1449,7 @@ static void property_release_bool(struct uc_struct *uc, Object *obj, const char
void *opaque)
{
BoolProperty *prop = opaque;
free(prop);
g_free(prop);
}
void object_property_add_bool(struct uc_struct *uc, Object *obj, const char *name,
@ -1470,7 +1470,7 @@ void object_property_add_bool(struct uc_struct *uc, Object *obj, const char *nam
prop, &local_err);
if (local_err) {
error_propagate(errp, local_err);
free(prop);
g_free(prop);
}
}
@ -1574,7 +1574,7 @@ static void property_release_alias(struct uc_struct *uc, Object *obj, const char
{
AliasProperty *prop = opaque;
free(prop);
g_free(prop);
}
void object_property_add_alias(Object *obj, const char *name,
@ -1610,7 +1610,7 @@ void object_property_add_alias(Object *obj, const char *name,
prop, &local_err);
if (local_err) {
error_propagate(errp, local_err);
free(prop);
g_free(prop);
goto out;
}
op->resolve = property_resolve_alias;
@ -1620,7 +1620,7 @@ void object_property_add_alias(Object *obj, const char *name,
&error_abort);
out:
free(prop_type);
g_free(prop_type);
}
void object_property_set_description(Object *obj, const char *name,
@ -1633,7 +1633,7 @@ void object_property_set_description(Object *obj, const char *name,
return;
}
free(op->description);
g_free(op->description);
op->description = g_strdup(description);
}

View File

@ -273,7 +273,7 @@ static void arm_cpu_initfn(struct uc_struct *uc, Object *obj, void *opaque)
cs->env_ptr = &cpu->env;
cpu_exec_init(&cpu->env, opaque);
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
free, free);
g_free, g_free);
#if 0
#ifndef CONFIG_USER_ONLY
@ -414,7 +414,7 @@ static ObjectClass *arm_cpu_class_by_name(struct uc_struct *uc, const char *cpu_
typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
oc = object_class_by_name(uc, typename);
free(typename);
g_free(typename);
if (!oc || !object_class_dynamic_cast(uc, oc, TYPE_ARM_CPU) ||
object_class_is_abstract(oc)) {
return NULL;
@ -1084,7 +1084,7 @@ static void cpu_register(struct uc_struct *uc, const ARMCPUInfo *info)
type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
type_register(uc, &type_info);
free((void *)type_info.name);
g_free((void *)type_info.name);
}
void arm_cpu_register_types(void *opaque)

View File

@ -212,7 +212,7 @@ static void aarch64_cpu_register(struct uc_struct *uc, const ARMCPUInfo *info)
type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
type_register(uc, &type_info);
free((void *)type_info.name);
g_free((void *)type_info.name);
}
void aarch64_cpu_register_types(void *opaque)

View File

@ -3102,7 +3102,7 @@ static void arm_cpu_list_entry(gpointer data, gpointer user_data)
name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_ARM_CPU));
(*s->cpu_fprintf)(s->file, " %s\n",
name);
free(name);
g_free(name);
}
#endif

View File

@ -23,13 +23,13 @@ void arm64_release(void* ctx)
{
TCGContext *s = (TCGContext *) ctx;
free(s->tb_ctx.tbs);
g_free(s->tb_ctx.tbs);
struct uc_struct* uc = s->uc;
ARMCPU* cpu = (ARMCPU*) uc->cpu;
free(cpu->cpreg_indexes);
free(cpu->cpreg_values);
free(cpu->cpreg_vmstate_indexes);
free(cpu->cpreg_vmstate_values);
g_free(cpu->cpreg_indexes);
g_free(cpu->cpreg_values);
g_free(cpu->cpreg_vmstate_indexes);
g_free(cpu->cpreg_vmstate_values);
release_common(ctx);
}

View File

@ -24,13 +24,13 @@ void arm_release(void* ctx)
{
TCGContext *s = (TCGContext *) ctx;
free(s->tb_ctx.tbs);
g_free(s->tb_ctx.tbs);
struct uc_struct* uc = s->uc;
ARMCPU* cpu = (ARMCPU*) uc->cpu;
free(cpu->cpreg_indexes);
free(cpu->cpreg_values);
free(cpu->cpreg_vmstate_indexes);
free(cpu->cpreg_vmstate_values);
g_free(cpu->cpreg_indexes);
g_free(cpu->cpreg_values);
g_free(cpu->cpreg_vmstate_indexes);
g_free(cpu->cpreg_vmstate_values);
release_common(ctx);
}

View File

@ -523,7 +523,7 @@ static ObjectClass *x86_cpu_class_by_name(struct uc_struct *uc, const char *cpu_
typename = x86_cpu_type_name(cpu_model);
oc = object_class_by_name(uc, typename);
free(typename);
g_free(typename);
return oc;
}
@ -1756,7 +1756,7 @@ static void x86_register_cpudef_type(struct uc_struct *uc, X86CPUDefinition *def
};
type_register(uc, &ti);
free(typename);
g_free(typename);
}
#if !defined(CONFIG_USER_ONLY)

View File

@ -1112,7 +1112,7 @@ void do_cpu_init(X86CPU *cpu)
memcpy(&env->start_init_save, &save->start_init_save,
offsetof(CPUX86State, end_init_save) -
offsetof(CPUX86State, start_init_save));
free(save);
g_free(save);
apic_init_reset(env->uc, cpu->apic_state);
}

View File

@ -29,21 +29,21 @@ void x86_release(void *ctx)
release_common(ctx);
// arch specific
free(s->cpu_A0);
free(s->cpu_T[0]);
free(s->cpu_T[1]);
free(s->cpu_tmp0);
free(s->cpu_tmp4);
free(s->cpu_cc_srcT);
free(s->cpu_cc_dst);
free(s->cpu_cc_src);
free(s->cpu_cc_src2);
g_free(s->cpu_A0);
g_free(s->cpu_T[0]);
g_free(s->cpu_T[1]);
g_free(s->cpu_tmp0);
g_free(s->cpu_tmp4);
g_free(s->cpu_cc_srcT);
g_free(s->cpu_cc_dst);
g_free(s->cpu_cc_src);
g_free(s->cpu_cc_src2);
for (i = 0; i < CPU_NB_REGS; ++i) {
free(s->cpu_regs[i]);
g_free(s->cpu_regs[i]);
}
free(s->tb_ctx.tbs);
g_free(s->tb_ctx.tbs);
}
void x86_reg_reset(struct uc_struct *uc)

View File

@ -74,7 +74,7 @@ static ObjectClass *m68k_cpu_class_by_name(struct uc_struct *uc, const char *cpu
typename = g_strdup_printf("%s-" TYPE_M68K_CPU, cpu_model);
oc = object_class_by_name(uc, typename);
free(typename);
g_free(typename);
if (oc != NULL && (object_class_dynamic_cast(uc, oc, TYPE_M68K_CPU) == NULL ||
object_class_is_abstract(oc))) {
return NULL;
@ -208,7 +208,7 @@ static void register_cpu_type(void *opaque, const M68kCPUInfo *info)
type_info.name = g_strdup_printf("%s-" TYPE_M68K_CPU, info->name);
type_register(opaque, &type_info);
free((void *)type_info.name);
g_free((void *)type_info.name);
}
void m68k_cpu_register_types(void *opaque)

View File

@ -22,24 +22,24 @@ void m68k_release(void* ctx)
{
release_common(ctx);
TCGContext *tcg_ctx = (TCGContext *) ctx;
free(tcg_ctx->tb_ctx.tbs);
free(tcg_ctx->QREG_PC);
free(tcg_ctx->QREG_SR);
free(tcg_ctx->QREG_CC_OP);
free(tcg_ctx->QREG_CC_DEST);
free(tcg_ctx->QREG_CC_SRC);
free(tcg_ctx->QREG_CC_X);
free(tcg_ctx->QREG_DIV1);
free(tcg_ctx->QREG_DIV2);
free(tcg_ctx->QREG_MACSR);
free(tcg_ctx->QREG_MAC_MASK);
g_free(tcg_ctx->tb_ctx.tbs);
g_free(tcg_ctx->QREG_PC);
g_free(tcg_ctx->QREG_SR);
g_free(tcg_ctx->QREG_CC_OP);
g_free(tcg_ctx->QREG_CC_DEST);
g_free(tcg_ctx->QREG_CC_SRC);
g_free(tcg_ctx->QREG_CC_X);
g_free(tcg_ctx->QREG_DIV1);
g_free(tcg_ctx->QREG_DIV2);
g_free(tcg_ctx->QREG_MACSR);
g_free(tcg_ctx->QREG_MAC_MASK);
int i;
for (i = 0; i < 8; i++) {
free(tcg_ctx->cpu_dregs[i]);
free(tcg_ctx->cpu_aregs[i]);
g_free(tcg_ctx->cpu_dregs[i]);
g_free(tcg_ctx->cpu_aregs[i]);
}
free(tcg_ctx->NULL_QREG);
free(tcg_ctx->store_dummy);
g_free(tcg_ctx->NULL_QREG);
g_free(tcg_ctx->store_dummy);
}
void m68k_reg_reset(struct uc_struct *uc)

View File

@ -46,24 +46,24 @@ void mips_release(void *ctx)
TCGContext *tcg_ctx = (TCGContext *) ctx;
release_common(ctx);
MIPSCPU* cpu = MIPS_CPU(tcg_ctx->uc, tcg_ctx->uc->cpu);
free(cpu->env.tlb);
free(cpu->env.mvp);
g_free(cpu->env.tlb);
g_free(cpu->env.mvp);
for (i = 0; i < MIPS_DSP_ACC; i++) {
free(tcg_ctx->cpu_HI[i]);
free(tcg_ctx->cpu_LO[i]);
g_free(tcg_ctx->cpu_HI[i]);
g_free(tcg_ctx->cpu_LO[i]);
}
for (i = 0; i < 32; i++) {
free(tcg_ctx->cpu_gpr[i]);
g_free(tcg_ctx->cpu_gpr[i]);
}
free(tcg_ctx->cpu_PC);
free(tcg_ctx->btarget);
free(tcg_ctx->bcond);
free(tcg_ctx->cpu_dspctrl);
g_free(tcg_ctx->cpu_PC);
g_free(tcg_ctx->btarget);
g_free(tcg_ctx->bcond);
g_free(tcg_ctx->cpu_dspctrl);
free(tcg_ctx->tb_ctx.tbs);
g_free(tcg_ctx->tb_ctx.tbs);
}
void mips_reg_reset(struct uc_struct *uc)

View File

@ -100,7 +100,7 @@ static int cpu_sparc_register(struct uc_struct *uc, SPARCCPU *cpu, const char *c
Error *err = NULL;
if (cpu_sparc_find_by_name(def, name) < 0) {
free(s);
g_free(s);
return -1;
}
@ -109,7 +109,7 @@ static int cpu_sparc_register(struct uc_struct *uc, SPARCCPU *cpu, const char *c
featurestr = strtok(NULL, ",");
cc->parse_features(CPU(cpu), featurestr, &err);
free(s);
g_free(s);
if (err) {
//error_report("%s", error_get_pretty(err));
error_free(err);
@ -821,7 +821,7 @@ static void sparc_cpu_uninitfn(struct uc_struct *uc, Object *obj, void *opaque)
SPARCCPU *cpu = SPARC_CPU(uc, obj);
CPUSPARCState *env = &cpu->env;
free(env->def);
g_free(env->def);
}
static void sparc_cpu_class_init(struct uc_struct *uc, ObjectClass *oc, void *data)

View File

@ -34,30 +34,30 @@ void sparc_release(void *ctx)
int i;
TCGContext *tcg_ctx = (TCGContext *) ctx;
release_common(ctx);
free(tcg_ctx->cpu_wim);
free(tcg_ctx->cpu_cond);
free(tcg_ctx->cpu_cc_src);
free(tcg_ctx->cpu_cc_src2);
free(tcg_ctx->cpu_cc_dst);
free(tcg_ctx->cpu_fsr);
free(tcg_ctx->sparc_cpu_pc);
free(tcg_ctx->cpu_npc);
free(tcg_ctx->cpu_y);
free(tcg_ctx->cpu_tbr);
g_free(tcg_ctx->cpu_wim);
g_free(tcg_ctx->cpu_cond);
g_free(tcg_ctx->cpu_cc_src);
g_free(tcg_ctx->cpu_cc_src2);
g_free(tcg_ctx->cpu_cc_dst);
g_free(tcg_ctx->cpu_fsr);
g_free(tcg_ctx->sparc_cpu_pc);
g_free(tcg_ctx->cpu_npc);
g_free(tcg_ctx->cpu_y);
g_free(tcg_ctx->cpu_tbr);
for (i = 0; i < 8; i++) {
free(tcg_ctx->cpu_gregs[i]);
g_free(tcg_ctx->cpu_gregs[i]);
}
for (i = 0; i < 32; i++) {
free(tcg_ctx->cpu_gpr[i]);
g_free(tcg_ctx->cpu_gpr[i]);
}
free(tcg_ctx->cpu_PC);
free(tcg_ctx->btarget);
free(tcg_ctx->bcond);
free(tcg_ctx->cpu_dspctrl);
g_free(tcg_ctx->cpu_PC);
g_free(tcg_ctx->btarget);
g_free(tcg_ctx->bcond);
g_free(tcg_ctx->cpu_dspctrl);
free(tcg_ctx->tb_ctx.tbs);
g_free(tcg_ctx->tb_ctx.tbs);
}
void sparc_reg_reset(struct uc_struct *uc)

View File

@ -299,7 +299,7 @@ void tcg_pool_reset(TCGContext *s)
TCGPool *p, *t;
for (p = s->pool_first_large; p; p = t) {
t = p->next;
free(p);
g_free(p);
}
s->pool_first_large = NULL;
s->pool_cur = s->pool_end = NULL;

View File

@ -142,7 +142,7 @@ static void tb_clean_internal(struct uc_struct *uc, int i, void** lp)
}
tb_clean_internal(uc, i-1, (*lp) + ((0 >> (i * V_L2_BITS)) & (V_L2_SIZE - 1)));
if (lp && *lp) {
free(*lp);
g_free(*lp);
}
}
@ -667,7 +667,7 @@ void free_code_gen_buffer(struct uc_struct *uc)
{
TCGContext *tcg_ctx = uc->tcg_ctx;
if (tcg_ctx->code_gen_buffer)
free(tcg_ctx->code_gen_buffer);
g_free(tcg_ctx->code_gen_buffer);
}
static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
@ -792,7 +792,7 @@ void tb_free(struct uc_struct *uc, TranslationBlock *tb)
static inline void invalidate_page_bitmap(PageDesc *p)
{
if (p->code_bitmap) {
free(p->code_bitmap);
g_free(p->code_bitmap);
p->code_bitmap = NULL;
}
p->code_write_count = 0;

View File

@ -32,14 +32,14 @@ static void release_common(void *t)
// Clean TCG.
TCGOpDef* def = &s->tcg_op_defs[0];
free(def->args_ct);
free(def->sorted_args);
free(s->tcg_op_defs);
g_free(def->args_ct);
g_free(def->sorted_args);
g_free(s->tcg_op_defs);
TCGPool *po, *to;
for (po = s->pool_first; po; po = to) {
to = po->next;
free(po);
g_free(po);
}
tcg_pool_reset(s);
g_hash_table_destroy(s->helpers);

View File

@ -67,7 +67,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
msg1 = g_strdup_vprintf(fmt, ap);
if (os_errno != 0) {
err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno));
free(msg1);
g_free(msg1);
} else {
err->msg = msg1;
}
@ -110,8 +110,8 @@ void error_set_win32(Error **errp, int win32_err, ErrorClass err_class,
char *msg2 = g_win32_error_message(win32_err);
err->msg = g_strdup_printf("%s: %s (error: %x)", msg1, msg2,
(unsigned)win32_err);
free(msg2);
free(msg1);
g_free(msg2);
g_free(msg1);
} else {
err->msg = msg1;
}
@ -152,8 +152,8 @@ const char *error_get_pretty(Error *err)
void error_free(Error *err)
{
if (err) {
free(err->msg);
free(err);
g_free(err->msg);
g_free(err);
}
}

View File

@ -288,9 +288,9 @@ QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
static void qemu_opt_del(QemuOpt *opt)
{
QTAILQ_REMOVE(&opt->opts->head, opt, next);
free(opt->name);
free(opt->str);
free(opt);
g_free(opt->name);
g_free(opt->str);
g_free(opt);
}
/* qemu_opt_set allows many settings for the same option.
@ -327,7 +327,7 @@ const char *qemu_opt_get(QemuOpts *opts, const char *name)
/* Get a known option (or its default) and remove it from the list
* all in one action. Return a malloced string of the option value.
* Result must be freed by caller with free().
* Result must be freed by caller with g_free().
*/
char *qemu_opt_get_del(QemuOpts *opts, const char *name)
{
@ -576,7 +576,7 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val)
opt->desc = find_desc_by_name(desc, name);
if (!opt->desc && !opts_accepts_any(opts)) {
qerror_report(QERR_INVALID_PARAMETER, name);
free(opt);
g_free(opt);
return -1;
}
@ -598,7 +598,7 @@ int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val)
opt->desc = find_desc_by_name(desc, name);
if (!opt->desc && !opts_accepts_any(opts)) {
qerror_report(QERR_INVALID_PARAMETER, name);
free(opt);
g_free(opt);
return -1;
}
@ -698,7 +698,7 @@ const char *qemu_opts_id(QemuOpts *opts)
return opts->id;
}
/* The id string will be free()d by qemu_opts_del */
/* The id string will be g_free()d by qemu_opts_del */
void qemu_opts_set_id(QemuOpts *opts, char *id)
{
opts->id = id;
@ -719,8 +719,8 @@ void qemu_opts_del(QemuOpts *opts)
qemu_opt_del(opt);
}
QTAILQ_REMOVE(&opts->list->head, opts, next);
free(opts->id);
free(opts);
g_free(opts->id);
g_free(opts);
}
void qemu_opts_print(QemuOpts *opts)
@ -1064,7 +1064,7 @@ static size_t count_opts_list(QemuOptsList *list)
void qemu_opts_free(QemuOptsList *list)
{
free(list);
g_free(list);
}
/* Realloc dst option list and append options from an option list (list)

View File

@ -277,7 +277,7 @@ static unsigned __stdcall win32_start_routine(void *arg)
if (data->mode == QEMU_THREAD_DETACHED) {
data->uc->qemu_thread_data = NULL;
free(data);
g_free(data);
data = NULL;
}
qemu_thread_exit(data->uc, start_routine(thread_arg));
@ -323,7 +323,7 @@ void *qemu_thread_join(QemuThread *thread)
ret = data->ret;
assert(data->mode != QEMU_THREAD_DETACHED);
DeleteCriticalSection(&data->cs);
free(data);
g_free(data);
return ret;
}

View File

@ -168,5 +168,5 @@ void qemu_register_machine(struct uc_struct *uc, QEMUMachine *m, const char *typ
ti.class_init = machine_class_init;
type_register(uc, &ti);
free(name);
g_free(name);
}

18
uc.c
View File

@ -28,10 +28,10 @@
static void free_table(gpointer key, gpointer value, gpointer data)
{
TypeInfo *ti = (TypeInfo*) value;
free((void*) ti->class);
free((void*) ti->name);
free((void*) ti->parent);
free((void*) ti);
g_free((void*) ti->class);
g_free((void*) ti->name);
g_free((void*) ti->parent);
g_free((void*) ti);
}
UNICORN_EXPORT
@ -287,12 +287,12 @@ uc_err uc_close(uc_engine *uc)
// Cleanup internally.
if (uc->release)
uc->release(uc->tcg_ctx);
free(uc->tcg_ctx);
g_free(uc->tcg_ctx);
// Cleanup CPU.
free(uc->cpu->tcg_as_listener);
free(uc->cpu->thread);
free(uc->cpu->halt_cond);
g_free(uc->cpu->tcg_as_listener);
g_free(uc->cpu->thread);
g_free(uc->cpu->halt_cond);
// Cleanup all objects.
OBJECT(uc->machine_state->accelerator)->ref = 1;
@ -309,7 +309,7 @@ uc_err uc_close(uc_engine *uc)
object_unref(uc, OBJECT(uc->root));
// System memory.
free(uc->system_memory);
g_free(uc->system_memory);
// Thread relateds.
if (uc->qemu_thread_data)