diff options
author | James Westman <james@jwestman.net> | 2022-09-10 19:11:30 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@ocrete.ca> | 2023-01-06 12:48:44 -0500 |
commit | f90200c058b15ced34ccc7b3af5453506c062633 (patch) | |
tree | 1da2fd4bfbd22561d69f96e3b531c74ca44465c6 | |
parent | 8671aed54a5a11eefa80552d5bb66c9a175c7179 (diff) |
address: Add introspection-friendly to_string_dup
nice_address_to_string expects an already-allocated string, which is not
great for introspection. Adds nice_address_to_string_dup, which does the
same thing, but returns a newly allocated string.
-rw-r--r-- | agent/address.c | 10 | ||||
-rw-r--r-- | agent/address.h | 15 | ||||
-rw-r--r-- | docs/reference/libnice/libnice-sections.txt | 1 | ||||
-rw-r--r-- | nice/libnice.sym | 1 |
4 files changed, 26 insertions, 1 deletions
diff --git a/agent/address.c b/agent/address.c index e1cc442..81795ae 100644 --- a/agent/address.c +++ b/agent/address.c @@ -261,6 +261,16 @@ nice_address_to_string (const NiceAddress *addr, gchar *dst) } } +NICEAPI_EXPORT gchar * +nice_address_dup_string (const NiceAddress *addr) +{ + char dst[MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)] = ""; + + nice_address_to_string (addr, dst); + + return g_strdup (dst); +} + NICEAPI_EXPORT gboolean nice_address_equal (const NiceAddress *a, const NiceAddress *b) diff --git a/agent/address.h b/agent/address.h index b0f5a52..f47b9aa 100644 --- a/agent/address.h +++ b/agent/address.h @@ -260,7 +260,7 @@ gboolean nice_address_equal_no_port (const NiceAddress *a, const NiceAddress *b); /** - * nice_address_to_string: + * nice_address_to_string: (skip) * @addr: The #NiceAddress to query * @dst: The string to fill * @@ -271,6 +271,19 @@ void nice_address_to_string (const NiceAddress *addr, gchar *dst); /** + * nice_address_dup_string: + * @addr: The #NiceAddress to query + * + * Transforms the address @addr into a newly allocated human readable string + * + * Returns: (transfer full): the address string + * + * Since: 0.1.20 + */ +gchar * +nice_address_dup_string (const NiceAddress *addr); + +/** * nice_address_is_private: * @addr: The #NiceAddress to query * diff --git a/docs/reference/libnice/libnice-sections.txt b/docs/reference/libnice/libnice-sections.txt index 1ae06de..011e8fd 100644 --- a/docs/reference/libnice/libnice-sections.txt +++ b/docs/reference/libnice/libnice-sections.txt @@ -145,6 +145,7 @@ nice_address_copy_to_sockaddr nice_address_equal nice_address_equal_no_port nice_address_to_string +nice_address_dup_string nice_address_is_private nice_address_is_linklocal nice_address_is_valid diff --git a/nice/libnice.sym b/nice/libnice.sym index 472c677..e2dc28a 100644 --- a/nice/libnice.sym +++ b/nice/libnice.sym @@ -2,6 +2,7 @@ nice_address_copy_to_sockaddr nice_address_dup nice_address_equal nice_address_equal_no_port +nice_address_dup_string nice_address_free nice_address_get_port nice_address_get_type |