From 01bcde8ab007792963fd5dc58d0f24531beef260 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 4 May 2022 22:00:16 +0200 Subject: [PATCH] glib-aux: add nm_g_bytes_ref() helper g_bytes_ref() does not accept NULL. But doing so can be convenient, add a helper for that. Note that g_bytes_unref() does accept NULL, so there is no corresponding helper. (cherry picked from commit 222f4049284160d1b55e79789224800d988724e8) --- src/libnm-glib-aux/nm-shared-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index 52cf1d4c32..596eaccd05 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -623,6 +623,16 @@ nm_utils_is_separator(const char c) /*****************************************************************************/ +static inline GBytes * +nm_g_bytes_ref(GBytes *b) +{ + if (b) + g_bytes_ref(b); + return b; +} + +/*****************************************************************************/ + GBytes *nm_g_bytes_get_empty(void); GBytes *nm_g_bytes_new_from_str(const char *str);