mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
qom: introduce object_class_get_list_sorted
Unify half a dozen copies of very similar code (the only difference being whether comparisons were case-sensitive) and use it also in Tricore, which did not do any sorting of CPU model names. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
819fd4699c
commit
47c66009ab
8 changed files with 30 additions and 65 deletions
13
qom/object.c
13
qom/object.c
|
@ -891,6 +891,19 @@ GSList *object_class_get_list(const char *implements_type,
|
|||
return list;
|
||||
}
|
||||
|
||||
static gint object_class_cmp(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return strcasecmp(object_class_get_name((ObjectClass *)a),
|
||||
object_class_get_name((ObjectClass *)b));
|
||||
}
|
||||
|
||||
GSList *object_class_get_list_sorted(const char *implements_type,
|
||||
bool include_abstract)
|
||||
{
|
||||
return g_slist_sort(object_class_get_list(implements_type, include_abstract),
|
||||
object_class_cmp);
|
||||
}
|
||||
|
||||
void object_ref(Object *obj)
|
||||
{
|
||||
if (!obj) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue