diff --git a/qemu/accel.c b/qemu/accel.c index bd6f59b7..3de5416c 100644 --- a/qemu/accel.c +++ b/qemu/accel.c @@ -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; } diff --git a/qemu/cpus.c b/qemu/cpus.c index 78edfa08..bf391467 100644 --- a/qemu/cpus.c +++ b/qemu/cpus.c @@ -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); diff --git a/qemu/exec.c b/qemu/exec.c index 21add4fb..92f26641 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -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; diff --git a/qemu/glib_compat.c b/qemu/glib_compat.c index 0018ecac..b63aed3c 100644 --- a/qemu/glib_compat.c +++ b/qemu/glib_compat.c @@ -501,6 +501,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; diff --git a/qemu/hw/core/qdev.c b/qemu/hw/core/qdev.c index 0c79225b..14e3ccec 100644 --- a/qemu/hw/core/qdev.c +++ b/qemu/hw/core/qdev.c @@ -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 = { diff --git a/qemu/hw/sparc/sun4m.c b/qemu/hw/sparc/sun4m.c index c7828388..3e9ac2b7 100644 --- a/qemu/hw/sparc/sun4m.c +++ b/qemu/hw/sparc/sun4m.c @@ -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; } diff --git a/qemu/include/glib_compat.h b/qemu/include/glib_compat.h index 2a8c5f6d..b8d63987 100644 --- a/qemu/include/glib_compat.h +++ b/qemu/include/glib_compat.h @@ -102,6 +102,7 @@ GHashTable *g_hash_table_ref(GHashTable *hash_table); guint g_hash_table_size(GHashTable *hash_table); /* replacement for g_malloc dependency */ +void g_free(void *ptr); void *g_malloc(size_t size); void *g_malloc0(size_t size); void *g_try_malloc0(size_t size); diff --git a/qemu/include/hw/arm/arm.h b/qemu/include/hw/arm/arm.h index 82bd5985..9e38953d 100644 --- a/qemu/include/hw/arm/arm.h +++ b/qemu/include/hw/arm/arm.h @@ -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 diff --git a/qemu/include/qemu/osdep.h b/qemu/include/qemu/osdep.h index cc6aa396..c593826e 100644 --- a/qemu/include/qemu/osdep.h +++ b/qemu/include/qemu/osdep.h @@ -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); /** diff --git a/qemu/include/qom/object.h b/qemu/include/qom/object.h index c539b422..93298b53 100644 --- a/qemu/include/qom/object.h +++ b/qemu/include/qom/object.h @@ -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 * diff --git a/qemu/memory.c b/qemu/memory.c index baf6b697..453ddce1 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -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) diff --git a/qemu/memory_mapping.c b/qemu/memory_mapping.c index 88168ade..324daa86 100644 --- a/qemu/memory_mapping.c +++ b/qemu/memory_mapping.c @@ -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; } diff --git a/qemu/qapi/qapi-dealloc-visitor.c b/qemu/qapi/qapi-dealloc-visitor.c index 19d2944c..a14a1c71 100644 --- a/qemu/qapi/qapi-dealloc-visitor.c +++ b/qemu/qapi/qapi-dealloc-visitor.c @@ -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) diff --git a/qemu/qapi/qapi-visit-core.c b/qemu/qapi/qapi-visit-core.c index ff5f8b9f..b66b93ae 100644 --- a/qemu/qapi/qapi-visit-core.c +++ b/qemu/qapi/qapi-visit-core.c @@ -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; } diff --git a/qemu/qapi/qmp-input-visitor.c b/qemu/qapi/qmp-input-visitor.c index 564134b9..d8612062 100644 --- a/qemu/qapi/qmp-input-visitor.c +++ b/qemu/qapi/qmp-input-visitor.c @@ -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) diff --git a/qemu/qapi/qmp-output-visitor.c b/qemu/qapi/qmp-output-visitor.c index 9e54cbe3..96b33846 100644 --- a/qemu/qapi/qmp-output-visitor.c +++ b/qemu/qapi/qmp-output-visitor.c @@ -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) diff --git a/qemu/qapi/string-input-visitor.c b/qemu/qapi/string-input-visitor.c index de1b26d8..d8a8db02 100644 --- a/qemu/qapi/string-input-visitor.c +++ b/qemu/qapi/string-input-visitor.c @@ -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) diff --git a/qemu/qemu-timer.c b/qemu/qemu-timer.c index 26c6f01d..a4e8eb17 100644 --- a/qemu/qemu-timer.c +++ b/qemu/qemu-timer.c @@ -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) diff --git a/qemu/qobject/json-parser.c b/qemu/qobject/json-parser.c index 7273b290..4288267b 100644 --- a/qemu/qobject/json-parser.c +++ b/qemu/qobject/json-parser.c @@ -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); } } diff --git a/qemu/qobject/qbool.c b/qemu/qobject/qbool.c index d3ffbab3..a3d2afa8 100644 --- a/qemu/qobject/qbool.c +++ b/qemu/qobject/qbool.c @@ -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)); } diff --git a/qemu/qobject/qdict.c b/qemu/qobject/qdict.c index 28921760..ea239f08 100644 --- a/qemu/qobject/qdict.c +++ b/qemu/qobject/qdict.c @@ -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); diff --git a/qemu/qobject/qfloat.c b/qemu/qobject/qfloat.c index 60ccb4ed..7de0992d 100644 --- a/qemu/qobject/qfloat.c +++ b/qemu/qobject/qfloat.c @@ -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)); } diff --git a/qemu/qobject/qint.c b/qemu/qobject/qint.c index e31a543c..86b9b04f 100644 --- a/qemu/qobject/qint.c +++ b/qemu/qobject/qint.c @@ -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)); } diff --git a/qemu/qobject/qlist.c b/qemu/qobject/qlist.c index 8b70b4f2..1ced0de5 100644 --- a/qemu/qobject/qlist.c +++ b/qemu/qobject/qlist.c @@ -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); } diff --git a/qemu/qobject/qstring.c b/qemu/qobject/qstring.c index 3d27e719..607b7a14 100644 --- a/qemu/qobject/qstring.c +++ b/qemu/qobject/qstring.c @@ -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); } diff --git a/qemu/qom/cpu.c b/qemu/qom/cpu.c index 397dfaab..57922b5f 100644 --- a/qemu/qom/cpu.c +++ b/qemu/qom/cpu.c @@ -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; } diff --git a/qemu/qom/object.c b/qemu/qom/object.c index 46b5d4d3..7731bd5f 100644 --- a/qemu/qom/object.c +++ b/qemu/qom/object.c @@ -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); } diff --git a/qemu/target-arm/cpu.c b/qemu/target-arm/cpu.c index 1716bf60..3373be6b 100644 --- a/qemu/target-arm/cpu.c +++ b/qemu/target-arm/cpu.c @@ -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) diff --git a/qemu/target-arm/cpu64.c b/qemu/target-arm/cpu64.c index 442d964e..fcccd996 100644 --- a/qemu/target-arm/cpu64.c +++ b/qemu/target-arm/cpu64.c @@ -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) diff --git a/qemu/target-arm/helper.c b/qemu/target-arm/helper.c index 75589d80..b3ba828b 100644 --- a/qemu/target-arm/helper.c +++ b/qemu/target-arm/helper.c @@ -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 diff --git a/qemu/target-arm/unicorn_aarch64.c b/qemu/target-arm/unicorn_aarch64.c index bbd0b7fa..1d9fb328 100644 --- a/qemu/target-arm/unicorn_aarch64.c +++ b/qemu/target-arm/unicorn_aarch64.c @@ -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); } diff --git a/qemu/target-arm/unicorn_arm.c b/qemu/target-arm/unicorn_arm.c index 90c031be..9e7cf575 100644 --- a/qemu/target-arm/unicorn_arm.c +++ b/qemu/target-arm/unicorn_arm.c @@ -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); } diff --git a/qemu/target-i386/cpu.c b/qemu/target-i386/cpu.c index 3f8cc917..d8b58510 100644 --- a/qemu/target-i386/cpu.c +++ b/qemu/target-i386/cpu.c @@ -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) diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c index b059d87f..5341094e 100644 --- a/qemu/target-i386/helper.c +++ b/qemu/target-i386/helper.c @@ -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); } diff --git a/qemu/target-i386/unicorn.c b/qemu/target-i386/unicorn.c index bf64a5b4..5005c2f9 100644 --- a/qemu/target-i386/unicorn.c +++ b/qemu/target-i386/unicorn.c @@ -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) diff --git a/qemu/target-m68k/cpu.c b/qemu/target-m68k/cpu.c index 23d7e329..19e00067 100644 --- a/qemu/target-m68k/cpu.c +++ b/qemu/target-m68k/cpu.c @@ -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) diff --git a/qemu/target-m68k/unicorn.c b/qemu/target-m68k/unicorn.c index aa78a5f8..18befef0 100644 --- a/qemu/target-m68k/unicorn.c +++ b/qemu/target-m68k/unicorn.c @@ -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) diff --git a/qemu/target-mips/unicorn.c b/qemu/target-mips/unicorn.c index e4c8e3c1..3ca24390 100644 --- a/qemu/target-mips/unicorn.c +++ b/qemu/target-mips/unicorn.c @@ -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) diff --git a/qemu/target-sparc/cpu.c b/qemu/target-sparc/cpu.c index f1e88742..c3f779b7 100644 --- a/qemu/target-sparc/cpu.c +++ b/qemu/target-sparc/cpu.c @@ -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) diff --git a/qemu/target-sparc/unicorn.c b/qemu/target-sparc/unicorn.c index 28ebe2db..354d48ca 100644 --- a/qemu/target-sparc/unicorn.c +++ b/qemu/target-sparc/unicorn.c @@ -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) diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c index 788146fe..6c0a09cf 100644 --- a/qemu/tcg/tcg.c +++ b/qemu/tcg/tcg.c @@ -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; diff --git a/qemu/translate-all.c b/qemu/translate-all.c index 8c5d8a35..4f10c633 100644 --- a/qemu/translate-all.c +++ b/qemu/translate-all.c @@ -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; diff --git a/qemu/unicorn_common.h b/qemu/unicorn_common.h index 9be2e982..bd8b5f6c 100644 --- a/qemu/unicorn_common.h +++ b/qemu/unicorn_common.h @@ -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); diff --git a/qemu/util/error.c b/qemu/util/error.c index ae5af596..9c49facb 100644 --- a/qemu/util/error.c +++ b/qemu/util/error.c @@ -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); } } diff --git a/qemu/util/qemu-option.c b/qemu/util/qemu-option.c index 47b7d2f4..28d6b364 100644 --- a/qemu/util/qemu-option.c +++ b/qemu/util/qemu-option.c @@ -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) diff --git a/qemu/util/qemu-thread-win32.c b/qemu/util/qemu-thread-win32.c index 8ee8826f..97ba69c6 100644 --- a/qemu/util/qemu-thread-win32.c +++ b/qemu/util/qemu-thread-win32.c @@ -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; } diff --git a/qemu/vl.c b/qemu/vl.c index b9656f6c..d25c8888 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -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); } diff --git a/uc.c b/uc.c index 8282a8ed..3738ab6f 100644 --- a/uc.c +++ b/uc.c @@ -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)