qemu-malloc.c: Remove qemu-specific heap routines.
Remove all uses of qemu_malloc/malloc0/realloc/free/strdup/etc to use
the equivalent GLib functions (g_malloc, g_free, ...) as per upstream.
This also removes qemu-malloc.c since it's no longer required.
Change-Id: I3c36a0396b73dd114b8da385b43f56a2e54dbb15
diff --git a/qobject/qbool.c b/qobject/qbool.c
index 5108dce..a3d2afa 100644
--- a/qobject/qbool.c
+++ b/qobject/qbool.c
@@ -31,7 +31,7 @@
{
QBool *qb;
- qb = qemu_malloc(sizeof(*qb));
+ qb = g_malloc(sizeof(*qb));
qb->value = value;
QOBJECT_INIT(qb, &qbool_type);
@@ -64,5 +64,5 @@
static void qbool_destroy_obj(QObject *obj)
{
assert(obj != NULL);
- qemu_free(qobject_to_qbool(obj));
+ g_free(qobject_to_qbool(obj));
}
diff --git a/qobject/qdict.c b/qobject/qdict.c
index f1faccd..7543ccc 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -35,7 +35,7 @@
{
QDict *qdict;
- qdict = qemu_mallocz(sizeof(*qdict));
+ qdict = g_malloc0(sizeof(*qdict));
QOBJECT_INIT(qdict, &qdict_type);
return qdict;
@@ -75,8 +75,8 @@
{
QDictEntry *entry;
- entry = qemu_mallocz(sizeof(*entry));
- entry->key = qemu_strdup(key);
+ entry = g_malloc0(sizeof(*entry));
+ entry->key = g_strdup(key);
entry->value = value;
return entry;
@@ -410,8 +410,8 @@
assert(e->value != NULL);
qobject_decref(e->value);
- qemu_free(e->key);
- qemu_free(e);
+ g_free(e->key);
+ g_free(e);
}
/**
@@ -452,5 +452,5 @@
}
}
- qemu_free(qdict);
+ g_free(qdict);
}
diff --git a/qobject/qerror.c b/qobject/qerror.c
index 0f47be0..40d0cbb 100644
--- a/qobject/qerror.c
+++ b/qobject/qerror.c
@@ -221,7 +221,7 @@
{
QError *qerr;
- qerr = qemu_mallocz(sizeof(*qerr));
+ qerr = g_malloc0(sizeof(*qerr));
QOBJECT_INIT(qerr, &qerror_type);
return qerr;
@@ -459,5 +459,5 @@
qerr = qobject_to_qerror(obj);
QDECREF(qerr->error);
- qemu_free(qerr);
+ g_free(qerr);
}
diff --git a/qobject/qfloat.c b/qobject/qfloat.c
index 08b2e57..7de0992 100644
--- a/qobject/qfloat.c
+++ b/qobject/qfloat.c
@@ -31,7 +31,7 @@
{
QFloat *qf;
- qf = qemu_malloc(sizeof(*qf));
+ qf = g_malloc(sizeof(*qf));
qf->value = value;
QOBJECT_INIT(qf, &qfloat_type);
@@ -64,5 +64,5 @@
static void qfloat_destroy_obj(QObject *obj)
{
assert(obj != NULL);
- qemu_free(qobject_to_qfloat(obj));
+ g_free(qobject_to_qfloat(obj));
}
diff --git a/qobject/qint.c b/qobject/qint.c
index fe33b8f..86b9b04 100644
--- a/qobject/qint.c
+++ b/qobject/qint.c
@@ -30,7 +30,7 @@
{
QInt *qi;
- qi = qemu_malloc(sizeof(*qi));
+ qi = g_malloc(sizeof(*qi));
qi->value = value;
QOBJECT_INIT(qi, &qint_type);
@@ -63,5 +63,5 @@
static void qint_destroy_obj(QObject *obj)
{
assert(obj != NULL);
- qemu_free(qobject_to_qint(obj));
+ g_free(qobject_to_qint(obj));
}
diff --git a/qobject/qlist.c b/qobject/qlist.c
index f7b3897..815b6aa 100644
--- a/qobject/qlist.c
+++ b/qobject/qlist.c
@@ -31,7 +31,7 @@
{
QList *qlist;
- qlist = qemu_malloc(sizeof(*qlist));
+ qlist = g_malloc(sizeof(*qlist));
QTAILQ_INIT(&qlist->head);
QOBJECT_INIT(qlist, &qlist_type);
@@ -64,7 +64,7 @@
{
QListEntry *entry;
- entry = qemu_malloc(sizeof(*entry));
+ entry = g_malloc(sizeof(*entry));
entry->value = value;
QTAILQ_INSERT_TAIL(&qlist->head, entry, next);
@@ -98,7 +98,7 @@
QTAILQ_REMOVE(&qlist->head, entry, next);
ret = entry->value;
- qemu_free(entry);
+ g_free(entry);
return ret;
}
@@ -150,8 +150,8 @@
QTAILQ_FOREACH_SAFE(entry, &qlist->head, next, next_entry) {
QTAILQ_REMOVE(&qlist->head, entry, next);
qobject_decref(entry->value);
- qemu_free(entry);
+ g_free(entry);
}
- qemu_free(qlist);
+ g_free(qlist);
}
diff --git a/qobject/qstring.c b/qobject/qstring.c
index 77bd4c7..5f7376c 100644
--- a/qobject/qstring.c
+++ b/qobject/qstring.c
@@ -40,12 +40,12 @@
{
QString *qstring;
- qstring = qemu_malloc(sizeof(*qstring));
+ qstring = g_malloc(sizeof(*qstring));
qstring->length = end - start + 1;
qstring->capacity = qstring->length;
- qstring->string = qemu_malloc(qstring->capacity + 1);
+ qstring->string = g_malloc(qstring->capacity + 1);
memcpy(qstring->string, str + start, qstring->length);
qstring->string[qstring->length] = 0;
@@ -70,7 +70,7 @@
qstring->capacity += len;
qstring->capacity *= 2; /* use exponential growth */
- qstring->string = qemu_realloc(qstring->string, qstring->capacity + 1);
+ qstring->string = g_realloc(qstring->string, qstring->capacity + 1);
}
}
@@ -136,6 +136,6 @@
assert(obj != NULL);
qs = qobject_to_qstring(obj);
- qemu_free(qs->string);
- qemu_free(qs);
+ g_free(qs->string);
+ g_free(qs);
}