[Spice-devel] [PATCH 0/3] spice interface redesign.

Alexander Larsson alexl at redhat.com
Wed Mar 31 05:31:31 PDT 2010


On Tue, 2010-03-30 at 12:10 +0200, Gerd Hoffmann wrote:
> Hi,
> 
> This is a early, RfC patch series for a spice interface redesign.
> For now only VDInterface, CoreInterface and KeyboardInterface are
> touched.  I'm sending them now to gather comments on the general
> direction and design.

Also, some specific comments:

+#ifndef container_of
+#define container_of(ptr, type, member) ({                      \
+        const typeof(((type *) 0)->member) *__mptr = (ptr);     \
+        (type *) ((char *) __mptr - offsetof(type, member));})
+#endif


You can use SPICE_CONTAINEROF from <spice/macros.h>

+    if (!is)
+        is = spice_malloc0(sizeof(*is));

You can use spice_new0(SpiceInterfaceState, 1) which is imho easier to
read (as its more obvious what type is created without having to go
look at the variable declaration). It does the casting of the newly
allocated object too, which is nice for C++ code (for the client or
common code).

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
       alexl at redhat.com            alexander.larsson at gmail.com 
He's an impetuous ninja card sharp with acid for blood. She's a supernatural 
Bolivian socialite from beyond the grave. They fight crime! 



More information about the Spice-devel mailing list