From: Bharata B Rao Date: Fri, 10 Jun 2016 00:59:00 +0000 (+0530) Subject: qom: API to get instance_size of a type X-Git-Tag: v2.7.0-rc0~114^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f97b53a682d2595747c926c00d78b9d406f1be0;p=thirdparty%2Fqemu.git qom: API to get instance_size of a type Add an API object_type_get_size(const char *typename) that returns the instance_size of the give typename. Signed-off-by: Bharata B Rao Signed-off-by: David Gibson --- diff --git a/include/qom/object.h b/include/qom/object.h index 99de539e7c7..2f8ac47c7c9 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1607,5 +1607,11 @@ int object_child_foreach_recursive(Object *obj, */ Object *container_get(Object *root, const char *path); - +/** + * object_type_get_instance_size: + * @typename: Name of the Type whose instance_size is required + * + * Returns the instance_size of the given @typename. + */ +size_t object_type_get_instance_size(const char *typename); #endif diff --git a/qom/object.c b/qom/object.c index 3bc8a009bbe..0311414c0a5 100644 --- a/qom/object.c +++ b/qom/object.c @@ -202,6 +202,14 @@ static size_t type_object_get_size(TypeImpl *ti) return 0; } +size_t object_type_get_instance_size(const char *typename) +{ + TypeImpl *type = type_get_by_name(typename); + + g_assert(type != NULL); + return type_object_get_size(type); +} + static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type) { assert(target_type);