summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-08-20 19:05:10 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-08-20 19:05:10 +0000
commitbe52c05a25c0cbadcd605b24d66d0c0b682aee18 (patch)
tree89abaf343d91156a88500480e75e9cdc3247198e /common
parentafa617e410dad21b496539c2c7e89124294f33ae (diff)
First round of Passkey Release method support
Diffstat (limited to 'common')
-rw-r--r--common/glib-ectomy.c18
-rw-r--r--common/list.c10
-rw-r--r--common/list.h2
3 files changed, 19 insertions, 11 deletions
diff --git a/common/glib-ectomy.c b/common/glib-ectomy.c
index fb737642..214ee571 100644
--- a/common/glib-ectomy.c
+++ b/common/glib-ectomy.c
@@ -161,14 +161,6 @@ guint g_io_add_watch(GIOChannel *channel, GIOCondition condition,
func, user_data, NULL);
}
-static void timeout_free(void *data, void *user_data)
-{
- struct timeout *t = data;
-
- if (t)
- free (t);
-}
-
static GMainContext *g_main_context_default()
{
if (default_context)
@@ -342,16 +334,19 @@ void g_main_loop_run(GMainLoop *loop)
void g_main_loop_quit(GMainLoop *loop)
{
- struct watch *w;
+ struct watch *w, *next;
loop->bail = 1;
- for (w = watch_head.next; w; w = w->next) {
+ for (w = watch_head.next; w; w = next) {
+ next = w->next;
if (w->destroy)
w->destroy(w->user_data);
watch_head.next = w->next;
free(w);
}
+
+ watch_head.next = NULL;
}
void g_main_loop_unref(GMainLoop *loop)
@@ -359,9 +354,10 @@ void g_main_loop_unref(GMainLoop *loop)
if (!loop->context)
return;
- slist_foreach(loop->context->ltimeout, timeout_free, NULL);
+ slist_foreach(loop->context->ltimeout, (slist_func_t)free, NULL);
slist_free(loop->context->ltimeout);
free(loop->context);
+ loop->context = NULL;
}
guint g_timeout_add(guint interval, GSourceFunc function, gpointer data)
diff --git a/common/list.c b/common/list.c
index 31ae9d35..42d377b7 100644
--- a/common/list.c
+++ b/common/list.c
@@ -99,6 +99,16 @@ struct slist *slist_find(struct slist *list, const void *data,
return NULL;
}
+int slist_length(struct slist *list)
+{
+ int len;
+
+ for (len = 0; list != NULL; list = list->next)
+ len++;
+
+ return len;
+}
+
void slist_foreach(struct slist *list, slist_func_t func, void *user_data)
{
while (list) {
diff --git a/common/list.h b/common/list.h
index 026d470c..c43756a9 100644
--- a/common/list.h
+++ b/common/list.h
@@ -40,6 +40,8 @@ struct slist *slist_remove(struct slist *list, void *data);
struct slist *slist_find(struct slist *list, const void *data,
cmp_func_t cmp_func);
+int slist_length(struct slist *list);
+
void slist_foreach(struct slist *list, slist_func_t func, void *user_data);
void slist_free(struct slist *list);