diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-20 22:09:37 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-20 23:01:08 -0500 |
commit | 7267c0947d7e8ae5dff7bafd932c3bc285f43e5c (patch) | |
tree | 9aa05d6e05ed83e67bf014f6745a3081b8407dc5 /hw/qdev.c | |
parent | 14015304b662e8f8ccce46c5a6927af6a14c510b (diff) | |
download | hqemu-7267c0947d7e8ae5dff7bafd932c3bc285f43e5c.zip hqemu-7267c0947d7e8ae5dff7bafd932c3bc285f43e5c.tar.gz |
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r-- | hw/qdev.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -85,7 +85,7 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) DeviceState *dev; assert(bus->info == info->bus_info); - dev = qemu_mallocz(info->size); + dev = g_malloc0(info->size); dev->info = info; dev->parent_bus = bus; qdev_prop_set_defaults(dev, dev->info->props); @@ -408,7 +408,7 @@ void qdev_free(DeviceState *dev) prop->info->free(dev, prop); } } - qemu_free(dev); + g_free(dev); } void qdev_machine_creation_done(void) @@ -750,17 +750,17 @@ void qbus_create_inplace(BusState *bus, BusInfo *info, if (name) { /* use supplied name */ - bus->name = qemu_strdup(name); + bus->name = g_strdup(name); } else if (parent && parent->id) { /* parent device has id -> use it for bus name */ len = strlen(parent->id) + 16; - buf = qemu_malloc(len); + buf = g_malloc(len); snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus); bus->name = buf; } else { /* no id -> use lowercase bus type for bus name */ len = strlen(info->name) + 16; - buf = qemu_malloc(len); + buf = g_malloc(len); len = snprintf(buf, len, "%s.%d", info->name, parent ? parent->num_child_bus : 0); for (i = 0; i < len; i++) @@ -783,7 +783,7 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name) { BusState *bus; - bus = qemu_mallocz(info->size); + bus = g_malloc0(info->size); bus->qdev_allocated = 1; qbus_create_inplace(bus, info, parent, name); return bus; @@ -793,7 +793,7 @@ static void main_system_bus_create(void) { /* assign main_system_bus before qbus_create_inplace() * in order to make "if (bus != main_system_bus)" work */ - main_system_bus = qemu_mallocz(system_bus_info.size); + main_system_bus = g_malloc0(system_bus_info.size); main_system_bus->qdev_allocated = 1; qbus_create_inplace(main_system_bus, &system_bus_info, NULL, "main-system-bus"); @@ -813,9 +813,9 @@ void qbus_free(BusState *bus) assert(bus != main_system_bus); /* main_system_bus is never freed */ qemu_unregister_reset(qbus_reset_all_fn, bus); } - qemu_free((void*)bus->name); + g_free((void*)bus->name); if (bus->qdev_allocated) { - qemu_free(bus); + g_free(bus); } } @@ -935,7 +935,7 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size) if (dev->parent_bus->info->get_fw_dev_path) { d = dev->parent_bus->info->get_fw_dev_path(dev); l += snprintf(p + l, size - l, "%s", d); - qemu_free(d); + g_free(d); } else { l += snprintf(p + l, size - l, "%s", dev->info->name); } |