mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-25 10:40:43 +01:00
libnm: add nm_utils_uuid_generate_buf() util
This commit is contained in:
parent
37bf643213
commit
e36f6a7e52
2 changed files with 25 additions and 7 deletions
|
|
@ -194,6 +194,14 @@ char *nm_utils_uuid_generate_from_string (const char *s, gssize slen, int uuid_t
|
|||
|
||||
char *_nm_utils_uuid_generate_from_strings (const char *string1, ...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
char *nm_utils_uuid_generate_buf_ (char *buf);
|
||||
#define nm_utils_uuid_generate_buf(buf) \
|
||||
({ \
|
||||
G_STATIC_ASSERT (sizeof (buf) == G_N_ELEMENTS (buf) && sizeof (buf) >= 37); \
|
||||
nm_utils_uuid_generate_buf_ (buf); \
|
||||
})
|
||||
#define nm_utils_uuid_generate_a() (nm_utils_uuid_generate_buf_ (g_alloca (37)))
|
||||
|
||||
void _nm_dbus_errors_init (void);
|
||||
|
||||
extern gboolean _nm_utils_is_manager_process;
|
||||
|
|
|
|||
|
|
@ -2146,6 +2146,22 @@ next:
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_utils_uuid_generate_buf_:
|
||||
* @buf: input buffer, must contain at least 37 bytes
|
||||
*
|
||||
* Returns: generates a new random UUID, writes it to @buf and returns @buf.
|
||||
**/
|
||||
char *
|
||||
nm_utils_uuid_generate_buf_ (char *buf)
|
||||
{
|
||||
uuid_t uuid;
|
||||
|
||||
uuid_generate_random (uuid);
|
||||
uuid_unparse_lower (uuid, buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_uuid_generate:
|
||||
*
|
||||
|
|
@ -2155,13 +2171,7 @@ next:
|
|||
char *
|
||||
nm_utils_uuid_generate (void)
|
||||
{
|
||||
uuid_t uuid;
|
||||
char *buf;
|
||||
|
||||
buf = g_malloc0 (37);
|
||||
uuid_generate_random (uuid);
|
||||
uuid_unparse_lower (uuid, &buf[0]);
|
||||
return buf;
|
||||
return nm_utils_uuid_generate_buf_ (g_malloc (37));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue