Core: Alter the kernel string functions to use std::string instead of const char*.

Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
This commit is contained in:
Lioncash 2014-08-17 23:03:22 -04:00
parent 68c81f28d9
commit 98fa3f7cba
16 changed files with 38 additions and 41 deletions

View file

@ -2,13 +2,12 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <stdio.h>
#include <list>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <list>
#include <map>
#include <string>
#include <vector>
#include "common/common.h"
#include "common/thread_queue_list.h"
@ -25,8 +24,8 @@ namespace Kernel {
class Thread : public Kernel::Object {
public:
const char* GetName() const { return name; }
const char* GetTypeName() const { return "Thread"; }
std::string GetName() const { return name; }
std::string GetTypeName() const { return "Thread"; }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Thread; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Thread; }
@ -71,7 +70,7 @@ public:
std::vector<Handle> waiting_threads;
char name[Kernel::MAX_NAME_LENGTH + 1];
std::string name;
};
// Lists all thread ids that aren't deleted/etc.
@ -336,9 +335,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
thread->processor_id = processor_id;
thread->wait_type = WAITTYPE_NONE;
thread->wait_handle = 0;
strncpy(thread->name, name, Kernel::MAX_NAME_LENGTH);
thread->name[Kernel::MAX_NAME_LENGTH] = '\0';
thread->name = name;
return thread;
}