Commit 898f7a56 authored by Thomas Haller's avatar Thomas Haller

libnm: add internal API nm_utils_inet*_ntop_dup()

In quite some cases we need the string representation on the heap.

While nm_utils_inet*_ntop() accepts NULL as output buffer to fallback
to a static buffer, such usage of a static buffer is discouraged.
So, we actually should always allocate a temporaray buffer on the
stack. But that is cumbersome to write.

Add simple wrappers that makes calling this more convenient.
parent 1e4c0dd6
......@@ -496,6 +496,30 @@ NMSettingBluetooth *_nm_connection_get_setting_bluetooth_for_nap (NMConnection *
const char *nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst);
static inline char *
nm_utils_inet4_ntop_dup (in_addr_t addr)
{
char buf[NM_UTILS_INET_ADDRSTRLEN];
return g_strdup (nm_utils_inet4_ntop (addr, buf));
}
static inline char *
nm_utils_inet6_ntop_dup (const struct in6_addr *addr)
{
char buf[NM_UTILS_INET_ADDRSTRLEN];
return g_strdup (nm_utils_inet6_ntop (addr, buf));
}
static inline char *
nm_utils_inet_ntop_dup (int addr_family, const struct in6_addr *addr)
{
char buf[NM_UTILS_INET_ADDRSTRLEN];
return g_strdup (nm_utils_inet_ntop (addr_family, addr, buf));
}
gboolean _nm_utils_inet6_is_token (const struct in6_addr *in6addr);
/*****************************************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment