summaryrefslogtreecommitdiff
path: root/libnm-core/nm-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core/nm-utils.c')
-rw-r--r--libnm-core/nm-utils.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index cfd97149ca..41b6304c82 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -2147,24 +2147,34 @@ next:
/*****************************************************************************/
/**
- * nm_utils_uuid_generate:
+ * nm_utils_uuid_generate_buf_:
+ * @buf: input buffer, must contain at least 37 bytes
*
- * Returns: a newly allocated UUID suitable for use as the #NMSettingConnection
- * object's #NMSettingConnection:id: property. Should be freed with g_free()
+ * Returns: generates a new random UUID, writes it to @buf and returns @buf.
**/
char *
-nm_utils_uuid_generate (void)
+nm_utils_uuid_generate_buf_ (char *buf)
{
uuid_t uuid;
- char *buf;
- buf = g_malloc0 (37);
uuid_generate_random (uuid);
- uuid_unparse_lower (uuid, &buf[0]);
+ uuid_unparse_lower (uuid, buf);
return buf;
}
/**
+ * nm_utils_uuid_generate:
+ *
+ * Returns: a newly allocated UUID suitable for use as the #NMSettingConnection
+ * object's #NMSettingConnection:id: property. Should be freed with g_free()
+ **/
+char *
+nm_utils_uuid_generate (void)
+{
+ return nm_utils_uuid_generate_buf_ (g_malloc (37));
+}
+
+/**
* nm_utils_uuid_generate_from_string:
* @s: a string to use as the seed for the UUID
* @slen: if negative, treat @s as zero terminated C string.