diff options
-rw-r--r-- | block.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -3744,11 +3744,17 @@ const char *bdrv_get_format_name(BlockDriverState *bs) return bs->drv ? bs->drv->format_name : NULL; } +static int qsort_strcmp(const void *a, const void *b) +{ + return strcmp(a, b); +} + void bdrv_iterate_format(void (*it)(void *opaque, const char *name), void *opaque) { BlockDriver *drv; int count = 0; + int i; const char **formats = NULL; QLIST_FOREACH(drv, &bdrv_drivers, list) { @@ -3762,10 +3768,16 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name), if (!found) { formats = g_renew(const char *, formats, count + 1); formats[count++] = drv->format_name; - it(opaque, drv->format_name); } } } + + qsort(formats, count, sizeof(formats[0]), qsort_strcmp); + + for (i = 0; i < count; i++) { + it(opaque, formats[i]); + } + g_free(formats); } |