On 06/13/2012 08:02 AM, Paolo Bonzini wrote: > Il 13/06/2012 14:59, Andreas Färber ha scritto: >> Ouch! One can argue that's still not recursive, but what matters more >> this borks Anthony's in-place object_initialize() concept. >> >> Two solutions come to mind: >> * allocate the interfaces as part of object_new() beyond instance_size > > That won't work if you initialize in place, because you cannot allocate > the room for the interface. It is possible to put Interface objects > explicitly in the class, and pass an offset when registering the type so > that they can be initialized in place. > > But I still think we're fighting windmills... There's no problem in my mind with allocating interfaces on the heap. in-place initialization is a readability thing, it's not a memory management thing. It's so you can see that: struct PIIX3 { ... RTCState rtc; APICState *apic; }; 'rtc' is a child and 'apic' is a link. Anyway, I don't like the idea of making interfaces concrete. That means that a user could directly instantiate an interface which doesn't make a lot of sense. Here's a different solution. This has not been even compile tested but I think the concept is sound. Regards, Anthony Liguori > > Paolo > >