summaryrefslogtreecommitdiff
path: root/gio/ginetaddress.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-05-25 11:33:56 +0200
committerAlexander Larsson <alexl@redhat.com>2009-05-25 11:33:56 +0200
commitce171195d99c57e895bb02c7b324c811f958a91f (patch)
treefc72b06f85011856423e688724527c5aa371dc5c /gio/ginetaddress.c
parentfb70c6420b63a17bed11b594dd7255df08424fec (diff)
downloadglib-ce171195d99c57e895bb02c7b324c811f958a91f.tar.gz
Add g_inet_address_get_native_size (#583205)
This can be used to get the size of g_inet_address_to_bytes().
Diffstat (limited to 'gio/ginetaddress.c')
-rw-r--r--gio/ginetaddress.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c
index 65accd4b3..dab26022e 100644
--- a/gio/ginetaddress.c
+++ b/gio/ginetaddress.c
@@ -482,7 +482,8 @@ g_inet_address_to_string (GInetAddress *address)
* Gets the raw binary address data from @address.
*
* Returns: a pointer to an internal array of the bytes in @address,
- * which should not be modified, stored, or freed.
+ * which should not be modified, stored, or freed. The size of this
+ * array can be gotten with g_inet_address_get_native_size().
*
* Since: 2.22
*/
@@ -495,6 +496,25 @@ g_inet_address_to_bytes (GInetAddress *address)
}
/**
+ * g_inet_address_get_native_size:
+ * @address: a #GInetAddress
+ *
+ * Gets the size of the native raw binary address for @address. This
+ * is the size of the data that you get from g_inet_address_to_bytes().
+ *
+ * Returns: the number of bytes used for the native version of @address.
+ *
+ * Since: 2.22
+ */
+gsize
+g_inet_address_get_native_size (GInetAddress *address)
+{
+ if (address->priv->family == AF_INET)
+ return sizeof (address->priv->addr.ipv4);
+ return sizeof (address->priv->addr.ipv6);
+}
+
+/**
* g_inet_address_get_family:
* @address: a #GInetAddress
*