qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 10/22] qapi: add core QMP server support


From: Daniel P. Berrange
Subject: Re: [Qemu-devel] [PATCH 10/22] qapi: add core QMP server support
Date: Mon, 7 Mar 2011 13:46:10 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Mar 07, 2011 at 07:39:41AM -0600, Anthony Liguori wrote:
> On 03/07/2011 07:09 AM, Stefan Hajnoczi wrote:
> >On Mon, Mar 7, 2011 at 1:22 AM, Anthony Liguori<address@hidden>  wrote:
> >>+char *qobject_as_string(QObject *obj)
> >>+{
> >>+    char buffer[1024];
> >>+
> >>+    switch (qobject_type(obj)) {
> >>+    case QTYPE_QINT:
> >>+        snprintf(buffer, sizeof(buffer), "%" PRId64,
> >>+                 qint_get_int(qobject_to_qint(obj)));
> >>+        return qemu_strdup(buffer);
> >>+    case QTYPE_QSTRING:
> >>+        return qemu_strdup(qstring_get_str(qobject_to_qstring(obj)));
> >>+    case QTYPE_QFLOAT:
> >>+        snprintf(buffer, sizeof(buffer), "%.17g",
> >>+                 qfloat_get_double(qobject_to_qfloat(obj)));
> >>+        return qemu_strdup(buffer);
> >qemu_asprintf() would be a nice helper function to have ;).
> 
> Indeed :-)

Since you've introduced glib, you get that function for free:

    g_strdup_printf()/g_strdup_vprintf()

similarly qemu_strdup & malloc related friends could be replaced with
the equivalent glib functions.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]