Re: [PATCH obexd 1/6 v2] Make use of g_slist_free_full when elements are dynamically-allocated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Jul 18, 2011 at 11:56 PM, Johan Hedberg <johan.hedberg@xxxxxxxxx> wrote:
> Hi Luiz,
>
> On Mon, Jul 18, 2011, Luiz Augusto von Dentz wrote:
>> This avoid having to iterate twice in the list to free its elements.
>> ---
>>  configure.ac                |    3 +++
>>  plugins/bluetooth.c         |    8 +++-----
>>  plugins/pbap.c              |    7 ++++---
>>  plugins/phonebook-dummy.c   |    3 +--
>>  plugins/phonebook-tracker.c |    5 ++---
>>  plugins/vcard.c             |   18 ++++++------------
>>  src/obex.h                  |    8 ++++++++
>>  7 files changed, 27 insertions(+), 25 deletions(-)
>
> Doesn't compile:
>
>  CC     plugins/vcard.o
> In file included from plugins/vcard.c:33:0:
> ./src/obex.h:66:51: error: unknown type name ‘obex_object_t’
> ./src/obex.h:68:48: error: unknown type name ‘obex_object_t’
> make[1]: *** [plugins/vcard.o] Error 1

How about handling this as a macro directly on AC_DEFINE e.g:

diff --git a/configure.ac b/configure.ac
index e02f218..40f4d9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,8 +72,11 @@ AC_CHECK_LIB(dl, dlopen, dummy=yes,
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
                                AC_MSG_ERROR(libglib 2.16 or later is required))
 AC_CHECK_LIB(glib-2.0, g_slist_free_full, dummy=yes,
-               AC_DEFINE(NEED_G_SLIST_FREE_FULL, 1,
-                       [Define to 1 if you need g_slist_free_full()
function.]))
+               AC_DEFINE(g_slist_free_full(list, destroy),
+               { \
+                       g_slist_foreach((GSList *) list, (GFunc)
destroy, NULL); \
+                       g_slist_free((GSList *) list); \
+               }, [Define if you need g_slist_free_full() function.]))
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)


This would work for whatever file that includes config.h which seems
to be the perfect place for wrappers like this, but it doesn't seems
common to have this type of macros inside configure.ac/config.h so
perhaps it is a bad idea.

-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux