From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVaQp-0001Pj-VQ for qemu-devel@nongnu.org; Fri, 05 Aug 2016 04:24:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVaQo-0001yh-VM for qemu-devel@nongnu.org; Fri, 05 Aug 2016 04:24:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33780) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVaQo-0001yb-PL for qemu-devel@nongnu.org; Fri, 05 Aug 2016 04:24:38 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DD2B680F6 for ; Fri, 5 Aug 2016 08:24:38 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Fri, 5 Aug 2016 12:23:48 +0400 Message-Id: <20160805082421.21994-4-marcandre.lureau@redhat.com> In-Reply-To: <20160805082421.21994-1-marcandre.lureau@redhat.com> References: <20160805082421.21994-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH for-2.7 v4 03/36] 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: pbonzini@redhat.com, eblake@redhat.com, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Those functions are only available since glib 2.28. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/glib-compat.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/glib-compat.h b/include/glib-compat.h index 01aa7b3..ff7eae5 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -260,4 +260,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.9.0