mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-22 06:50:07 +01:00
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.
This commit is contained in:
parent
1e4c0dd680
commit
898f7a5665
1 changed files with 24 additions and 0 deletions
|
|
@ -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);
|
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);
|
gboolean _nm_utils_inet6_is_token (const struct in6_addr *in6addr);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue