@@ -659,6 +659,14 @@ const char *object_get_typename(Object *obj);
Type type_register_static(const TypeInfo *info);
/**
+ * type_get_instance_size:
+ * @typename: The name of the #Type to obtain the object size for.
+ *
+ * Returns: The instance size of an object of type @typename.
+ */
+size_t type_get_instance_size(const char *typename);
+
+/**
* type_register:
* @info: The #TypeInfo of the new type
*
@@ -337,6 +337,13 @@ void object_initialize(void *data, size_t size, const char *typename)
object_initialize_with_type(data, size, type);
}
+size_t type_get_instance_size(const char *typename)
+{
+ TypeImpl *type = type_get_by_name(typename);
+
+ return type->instance_size;
+}
+
static inline bool object_property_is_child(ObjectProperty *prop)
{
return strstart(prop->type, "child<", NULL);
Helper to obtain the instance_size for a type. Signed-off-by: Andreas Färber <afaerber@suse.de> --- include/qom/object.h | 8 ++++++++ qom/object.c | 7 +++++++ 2 files changed, 15 insertions(+)