diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-03 08:33:10 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-12 15:21:10 +0100 |
commit | 47c66009ab793241e8210b3018c77a9ce9506aa8 (patch) | |
tree | db80a563159ab6069416b8c040e63eeedbeeaad0 /qom | |
parent | 819fd4699c7b36d574292bcbd8bc25e9d716c84b (diff) | |
download | qemu-47c66009ab793241e8210b3018c77a9ce9506aa8.zip qemu-47c66009ab793241e8210b3018c77a9ce9506aa8.tar.gz qemu-47c66009ab793241e8210b3018c77a9ce9506aa8.tar.bz2 |
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>
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c index 755ad03..6088f55 100644 --- a/qom/object.c +++ b/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) { |