From 98fa3f7cba22997aef8ec4d121584c2488389c38 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 17 Aug 2014 23:03:22 -0400 Subject: 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. --- src/core/hle/kernel/thread.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/core/hle/kernel/thread.cpp') diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 1d7ded6f6..554ec9756 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -2,13 +2,12 @@ // Licensed under GPLv2 // Refer to the license.txt file included. -#include - -#include #include -#include +#include +#include #include #include +#include #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 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; } -- cgit v1.2.3