On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote: > In order to be able to check whether a QOM type has been > registered, introduce the type_is_registered() helper. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> Reviewed-by: Eric Auger <eric.auger@xxxxxxxxxx> Eric > --- > include/qom/object.h | 8 ++++++++ > qom/object.c | 5 +++++ > 2 files changed, 13 insertions(+) > > diff --git a/include/qom/object.h b/include/qom/object.h > index 9192265db76..5b5333017e0 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -898,6 +898,14 @@ Type type_register_static(const TypeInfo *info); > */ > void type_register_static_array(const TypeInfo *infos, int nr_infos); > > +/** > + * type_is_registered: > + * @typename: The @typename to check. > + * > + * Returns: %true if @typename has been registered, %false otherwise. > + */ > +bool type_is_registered(const char *typename); > + > /** > * DEFINE_TYPES: > * @type_array: The array containing #TypeInfo structures to register > diff --git a/qom/object.c b/qom/object.c > index 01618d06bd8..be442980049 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -100,6 +100,11 @@ static TypeImpl *type_table_lookup(const char *name) > return g_hash_table_lookup(type_table_get(), name); > } > > +bool type_is_registered(const char *typename) > +{ > + return !!type_table_lookup(typename); > +} > + > static TypeImpl *type_new(const TypeInfo *info) > { > TypeImpl *ti = g_malloc0(sizeof(*ti));