Use std::sort instead of qsort in listdevices (nw)

This commit is contained in:
AJR 2017-01-31 20:49:04 -05:00
parent 36ba346bfb
commit ecf9eeefc2
2 changed files with 4 additions and 9 deletions

View File

@ -30,6 +30,7 @@
#include "language.h"
#include "pluginopts.h"
#include <algorithm>
#include <new>
#include <ctype.h>
@ -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)

View File

@ -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 = "*");