Revision aca59af6 qom/object.c

b/qom/object.c
177 177
    return sizeof(ObjectClass);
178 178
}
179 179

  
180
static size_t type_object_get_size(TypeImpl *ti)
181
{
182
    if (ti->instance_size) {
183
        return ti->instance_size;
184
    }
185

  
186
    if (type_has_parent(ti)) {
187
        return type_object_get_size(type_get_parent(ti));
188
    }
189

  
190
    return 0;
191
}
192

  
180 193
static void type_class_interface_init(TypeImpl *ti, InterfaceImpl *iface)
181 194
{
182 195
    TypeInfo info = {
......
203 216
    }
204 217

  
205 218
    ti->class_size = type_class_get_size(ti);
219
    ti->instance_size = type_object_get_size(ti);
206 220

  
207 221
    ti->class = g_malloc0(ti->class_size);
208 222
    ti->class->type = ti;
......
264 278
    Object *obj = data;
265 279

  
266 280
    g_assert(type != NULL);
267
    g_assert(type->instance_size >= sizeof(Object));
268

  
269 281
    type_class_init(type);
282

  
283
    g_assert(type->instance_size >= sizeof(Object));
270 284
    g_assert(type->abstract == false);
271 285

  
272 286
    memset(obj, 0, type->instance_size);
......
353 367
    Object *obj;
354 368

  
355 369
    g_assert(type != NULL);
370
    type_class_init(type);
356 371

  
357 372
    obj = g_malloc(type->instance_size);
358 373
    object_initialize_with_type(obj, type);

Also available in: Unified diff