[libc-commits] [libc] Implement inet_pton (PR #224644)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Tue Sep 22 02:32:32 PDT 2026
================
@@ -25,7 +25,8 @@
namespace LIBC_NAMESPACE_DECL {
namespace net {
-cpp::optional<in_addr_t> inet_addr(cpp::string_view src);
+int inet_addr(cpp::string_view src, void *dst);
+int inet_pton_v4(cpp::string_view src, void *dst);
----------------
labath wrote:
These functions don't have to match the official C signatures, and we should take the opportunity to make them safer to use. If you want to model this on inet_addr above, I'd suggest
```
cpp::optional<in_addr_t> inet_pton_ipv4(cpp::string_view src);
```
though personally, I'd probably try to match the functions below. So something like:
```
[[nodiscard]] bool str_to_ipv4(cpp::string_view src, struct in_addr &dst);
```
https://github.com/llvm/llvm-project/pull/224644
More information about the libc-commits
mailing list