From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD1Hp-00037g-Vb for qemu-devel@nongnu.org; Fri, 23 Aug 2013 20:01:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VD1Hi-0000mE-AM for qemu-devel@nongnu.org; Fri, 23 Aug 2013 20:01:01 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36501 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VD1Hi-0000m4-4S for qemu-devel@nongnu.org; Fri, 23 Aug 2013 20:00:54 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sat, 24 Aug 2013 02:00:34 +0200 Message-Id: <1377302436-25193-15-git-send-email-afaerber@suse.de> In-Reply-To: <1377302436-25193-1-git-send-email-afaerber@suse.de> References: <1377302436-25193-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 14/16] qom: Introduce type_get_instance_size() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Helper to obtain the instance_size for a type. Signed-off-by: Andreas F=C3=A4rber --- 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); =20 /** + * 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, cons= t char *typename) object_initialize_with_type(data, size, type); } =20 +size_t type_get_instance_size(const char *typename) +{ + TypeImpl *type =3D type_get_by_name(typename); + + return type->instance_size; +} + static inline bool object_property_is_child(ObjectProperty *prop) { return strstart(prop->type, "child<", NULL); --=20 1.8.1.4