Helper to obtain the instance_size for a type.
Signed-off-by: Andreas Färber <[email protected]>
---
include/qom/object.h | 8 ++++++++
qom/object.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index 1a7b71a..96b9ab4 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -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
*
diff --git a/qom/object.c b/qom/object.c
index e90e382..71322c3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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);
--
1.8.1.4