]> git.proxmox.com Git - qemu.git/blobdiff - error.c
Version 1.0.1
[qemu.git] / error.c
diff --git a/error.c b/error.c
index 867eec2c1af8e5cf555d5068086729e66d1484b2..990050f792f73b7dd04221e3e371ace802fcc456 100644 (file)
--- a/error.c
+++ b/error.c
@@ -9,11 +9,13 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.  See
  * the COPYING.LIB file in the top-level directory.
  */
+
+#include "qemu-common.h"
 #include "error.h"
+#include "qjson.h"
+#include "qdict.h"
 #include "error_int.h"
-#include "qemu-objects.h"
 #include "qerror.h"
-#include <assert.h>
 
 struct Error
 {
@@ -31,7 +33,7 @@ void error_set(Error **errp, const char *fmt, ...)
         return;
     }
 
-    err = qemu_mallocz(sizeof(*err));
+    err = g_malloc0(sizeof(*err));
 
     va_start(ap, fmt);
     err->obj = qobject_to_qdict(qobject_from_jsonv(fmt, &ap));
@@ -51,7 +53,7 @@ const char *error_get_pretty(Error *err)
     if (err->msg == NULL) {
         QString *str;
         str = qerror_format(err->fmt, err->obj);
-        err->msg = qemu_strdup(qstring_get_str(str));
+        err->msg = g_strdup(qstring_get_str(str));
         QDECREF(str);
     }
 
@@ -85,8 +87,8 @@ void error_free(Error *err)
 {
     if (err) {
         QDECREF(err->obj);
-        qemu_free(err->msg);
-        qemu_free(err);
+        g_free(err->msg);
+        g_free(err);
     }
 }
 
@@ -96,6 +98,10 @@ bool error_is_type(Error *err, const char *fmt)
     char *ptr;
     char *end;
 
+    if (!err) {
+        return false;
+    }
+
     ptr = strstr(fmt, "'class': '");
     assert(ptr != NULL);
     ptr += strlen("'class': '");
@@ -132,7 +138,7 @@ void error_set_qobject(Error **errp, QObject *obj)
     if (errp == NULL) {
         return;
     }
-    err = qemu_mallocz(sizeof(*err));
+    err = g_malloc0(sizeof(*err));
     err->obj = qobject_to_qdict(obj);
     qobject_incref(obj);