Received: from eggs.gnu.org ([2001:4830:134:3::10]:57237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi08y-00005c-MM for qemu-devel@nongnu.org; Thu, 08 Sep 2016 10:17:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bi08x-0000M6-L5 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 10:17:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi08x-0000Lx-Fj for qemu-devel@nongnu.org; Thu, 08 Sep 2016 10:17:31 -0400 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 8 Sep 2016 18:16:57 +0400 Message-Id: <20160908141720.30641-3-marcandre.lureau@redhat.com> In-Reply-To: <20160908141720.30641-1-marcandre.lureau@redhat.com> References: <20160908141720.30641-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULLv2 02/25] glib-compat: add g_(s)list_free_full() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, eblake@redhat.com, armbru@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Those functions are only available since glib 2.28. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/glib-compat.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/glib-compat.h b/include/glib-compat.h index 8d5a7f3..8093163 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -280,4 +280,28 @@ static inline void g_hash_table_add(GHashTable *hash= _table, gpointer key) } while (0) #endif =20 +#if !GLIB_CHECK_VERSION(2, 28, 0) +static inline void g_list_free_full(GList *list, GDestroyNotify free_fun= c) +{ + GList *l; + + for (l =3D list; l; l =3D l->next) { + free_func(l->data); + } + + g_list_free(list); +} + +static inline void g_slist_free_full(GSList *list, GDestroyNotify free_f= unc) +{ + GSList *l; + + for (l =3D list; l; l =3D l->next) { + free_func(l->data); + } + + g_slist_free(list); +} +#endif + #endif --=20 2.10.0