Kill off some usages of c_str.

Also changes some function params, but this is ok.
Some simplifications were also able to be made (ie. killing off strcmps with ==, etc).
This commit is contained in:
Lioncash
2014-03-12 15:33:41 -04:00
parent dccc6d8b47
commit a82675b7d5
170 changed files with 812 additions and 704 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <string>
#include <vector>
#include "Common/FifoQueue.h"
@ -23,7 +24,7 @@ namespace CoreTiming
struct EventType
{
TimedCallback callback;
const char *name;
std::string name;
};
std::vector<EventType> event_types;
@ -79,7 +80,7 @@ void FreeEvent(Event* ev)
static void EmptyTimedCallback(u64 userdata, int cyclesLate) {}
int RegisterEvent(const char *name, TimedCallback callback)
int RegisterEvent(const std::string& name, TimedCallback callback)
{
EventType type;
type.name = name;
@ -89,9 +90,9 @@ int RegisterEvent(const char *name, TimedCallback callback)
// we want event type names to remain unique so that we can use them for serialization.
for (auto& event_type : event_types)
{
if (!strcmp(name, event_type.name))
if (name == event_type.name)
{
WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name);
WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name.c_str());
// we don't know if someone might be holding on to the type index,
// so we gut the old event type instead of actually removing it.
event_type.name = "_discarded_event";
@ -154,7 +155,7 @@ void EventDoState(PointerWrap &p, BaseEvent* ev)
bool foundMatch = false;
for (unsigned int i = 0; i < event_types.size(); ++i)
{
if (!strcmp(name.c_str(), event_types[i].name))
if (name == event_types[i].name)
{
ev->type = i;
foundMatch = true;
@ -467,11 +468,9 @@ std::string GetScheduledEventsSummary()
if (t >= event_types.size())
PanicAlertT("Invalid event type %i", t);
const char *name = event_types[ptr->type].name;
if (!name)
name = "[unknown]";
const std::string& name = event_types[ptr->type].name;
text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name, ptr->time, ptr->userdata);
text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name.c_str(), ptr->time, ptr->userdata);
ptr = ptr->next;
}
return text;