mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 07:10:07 +01:00
glib-aux: add nm_strvarray_clear() helper
This commit is contained in:
parent
7ab9a2b69f
commit
73947cdfd0
1 changed files with 18 additions and 0 deletions
|
|
@ -3154,6 +3154,24 @@ _nm_strvarray_cmp_strv(const GArray *strv, const char *const *ss, gsize ss_len)
|
|||
#define nm_strvarray_equal_strv(strv, ss, ss_len) \
|
||||
(nm_strvarray_cmp_strv((strv), (ss), (ss_len)) == 0)
|
||||
|
||||
static inline gboolean
|
||||
nm_strvarray_clear(GArray **array)
|
||||
{
|
||||
gboolean cleared = FALSE;
|
||||
|
||||
nm_assert(array);
|
||||
nm_assert(!*array || sizeof(char *) == g_array_get_element_size(*array));
|
||||
|
||||
if (*array) {
|
||||
/* We always clear the GArray, but we return TRUE only if the
|
||||
* array was non-empty before. */
|
||||
if ((*array)->len > 0)
|
||||
cleared = TRUE;
|
||||
nm_clear_pointer(array, g_array_unref);
|
||||
}
|
||||
return cleared;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMVariantAttributeSpec {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue