summaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorJames Westman <james@jwestman.net>2022-09-10 19:11:30 -0500
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2023-01-06 12:48:44 -0500
commitf90200c058b15ced34ccc7b3af5453506c062633 (patch)
tree1da2fd4bfbd22561d69f96e3b531c74ca44465c6 /agent
parent8671aed54a5a11eefa80552d5bb66c9a175c7179 (diff)
downloadlibnice-f90200c058b15ced34ccc7b3af5453506c062633.tar.gz
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.
Diffstat (limited to 'agent')
-rw-r--r--agent/address.c10
-rw-r--r--agent/address.h15
2 files changed, 24 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
*