From ecf9eeefc2a9b99b9940a04cffe9dc50593dcdef Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 31 Jan 2017 20:49:04 -0500 Subject: [PATCH] Use std::sort instead of qsort in listdevices (nw) --- src/frontend/mame/clifront.cpp | 12 ++++-------- src/frontend/mame/clifront.h | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp index fd785ef8139..049b8fe10e8 100644 --- a/src/frontend/mame/clifront.cpp +++ b/src/frontend/mame/clifront.cpp @@ -30,6 +30,7 @@ #include "language.h" #include "pluginopts.h" +#include #include #include @@ -650,13 +651,6 @@ void cli_frontend::listsamples(const char *gamename) // referenced by a given game or set of games //------------------------------------------------- -int cli_frontend::compare_devices(const void *i1, const void *i2) -{ - device_t *dev1 = *(device_t **)i1; - device_t *dev2 = *(device_t **)i2; - return strcmp(dev1->tag(), dev2->tag()); -} - void cli_frontend::listdevices(const char *gamename) { // determine which drivers to output; return an error if none found @@ -680,7 +674,9 @@ void cli_frontend::listdevices(const char *gamename) device_list.push_back(&device); // sort them by tag - qsort(&device_list[0], device_list.size(), sizeof(device_list[0]), compare_devices); + std::sort(device_list.begin(), device_list.end(), [](device_t *dev1, device_t *dev2) { + return strcmp(dev1->tag(), dev2->tag()) < 0; + }); // dump the results for (auto device : device_list) diff --git a/src/frontend/mame/clifront.h b/src/frontend/mame/clifront.h index 4e3958cd5c3..544c2bbe15b 100644 --- a/src/frontend/mame/clifront.h +++ b/src/frontend/mame/clifront.h @@ -43,7 +43,6 @@ public: void listcrc(const char *gamename = "*"); void listroms(const char *gamename = "*"); void listsamples(const char *gamename = "*"); - static int compare_devices(const void *i1, const void *i2); void listdevices(const char *gamename = "*"); void listslots(const char *gamename = "*"); void listmedia(const char *gamename = "*");