summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp')
-rw-r--r--3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp21
1 files changed, 12 insertions, 9 deletions
diff --git a/3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp b/3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp
index adda630f81e..8a254ed6da1 100644
--- a/3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp
+++ b/3rdparty/asio/include/asio/local/detail/impl/endpoint.ipp
@@ -2,7 +2,7 @@
// local/detail/impl/endpoint.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Derived from a public domain implementation written by Daniel Casimiro.
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -48,6 +48,13 @@ endpoint::endpoint(const std::string& path_name)
init(path_name.data(), path_name.length());
}
+#if defined(ASIO_HAS_STRING_VIEW)
+endpoint::endpoint(string_view path_name)
+{
+ init(path_name.data(), path_name.length());
+}
+#endif // defined(ASIO_HAS_STRING_VIEW)
+
void endpoint::resize(std::size_t new_size)
{
if (new_size > sizeof(asio::detail::sockaddr_un_type))
@@ -105,16 +112,12 @@ void endpoint::init(const char* path_name, std::size_t path_length)
asio::detail::throw_error(ec);
}
- using namespace std; // For memcpy.
- data_.local = asio::detail::sockaddr_un_type();
+ using namespace std; // For memset and memcpy.
+ memset(&data_.local, 0, sizeof(asio::detail::sockaddr_un_type));
data_.local.sun_family = AF_UNIX;
- memcpy(data_.local.sun_path, path_name, path_length);
+ if (path_length > 0)
+ memcpy(data_.local.sun_path, path_name, path_length);
path_length_ = path_length;
-
- // NUL-terminate normal path names. Names that start with a NUL are in the
- // UNIX domain protocol's "abstract namespace" and are not NUL-terminated.
- if (path_length > 0 && data_.local.sun_path[0] == 0)
- data_.local.sun_path[path_length] = 0;
}
} // namespace detail