shared: add nm_g_bytes_new_from_str() helper
This commit is contained in:
@@ -364,6 +364,21 @@ again:
|
||||
return b;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
nm_g_bytes_new_from_str(const char *str)
|
||||
{
|
||||
gsize l;
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
/* the returned array is guaranteed to have a trailing '\0'
|
||||
* character *after* the length. */
|
||||
|
||||
l = strlen(str);
|
||||
return g_bytes_new_take(nm_memdup(str, l + 1u), l);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_gbytes_equals:
|
||||
* @bytes: (allow-none): a #GBytes array to compare. Note that
|
||||
|
@@ -319,6 +319,8 @@ nm_utils_is_separator(const char c)
|
||||
|
||||
GBytes *nm_gbytes_get_empty(void);
|
||||
|
||||
GBytes *nm_g_bytes_new_from_str(const char *str);
|
||||
|
||||
static inline gboolean
|
||||
nm_gbytes_equal0(GBytes *a, GBytes *b)
|
||||
{
|
||||
|
Reference in New Issue
Block a user