summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-06-13 21:41:07 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-06-15 06:13:00 +0200
commit53b4786037d8b040991eb7d2146ac11ebd8cb718 (patch)
treeb1fcdf91a2ea37efbf2ac59e9cb0863905d73de2 /src/network/core
parent667301e3ecc39ecd6bce286fafe25247d774642f (diff)
downloadopenttd-53b4786037d8b040991eb7d2146ac11ebd8cb718.tar.xz
Codechange: [Network] Let NetworkError return its std::string instead of a C-string
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/os_abstraction.cpp4
-rw-r--r--src/network/core/os_abstraction.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/network/core/os_abstraction.cpp b/src/network/core/os_abstraction.cpp
index b2d3475d0..202806a34 100644
--- a/src/network/core/os_abstraction.cpp
+++ b/src/network/core/os_abstraction.cpp
@@ -76,7 +76,7 @@ bool NetworkError::IsConnectInProgress() const
* Get the string representation of the error message.
* @return The string representation that will get overwritten by next calls.
*/
-const char *NetworkError::AsString() const
+const std::string &NetworkError::AsString() const
{
if (this->message.empty()) {
#if defined(_WIN32)
@@ -97,7 +97,7 @@ const char *NetworkError::AsString() const
this->message.assign(strerror(this->error));
#endif
}
- return this->message.c_str();
+ return this->message;
}
/**
diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h
index 8cf820255..fbde92c05 100644
--- a/src/network/core/os_abstraction.h
+++ b/src/network/core/os_abstraction.h
@@ -29,7 +29,7 @@ public:
bool WouldBlock() const;
bool IsConnectionReset() const;
bool IsConnectInProgress() const;
- const char *AsString() const;
+ const std::string &AsString() const;
static NetworkError GetLast();
};