Commit 3f97b53a authored by Bharata B Rao's avatar Bharata B Rao Committed by David Gibson
Browse files

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: default avatarBharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent aab99135
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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
+8 −0
Original line number Diff line number Diff line
@@ -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);