From 2afc40f3a62146ac0518cf6fa6d936c708f66d42 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Mon, 25 Aug 2003 16:20:41 +0000 Subject: [PATCH] When DISABLE_MEM_POOLS is set, loop through and free the poll records Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): When DISABLE_MEM_POOLS is set, loop through and free the poll records explicitely, since g_mem_chunk_destroy() won't do it. (#118121, Morten Welinder) --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ glib/gmain.c | 27 ++++++++++++++++++++++++++- 7 files changed, 68 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 636afdc..ccf7305 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Aug 25 12:17:20 2003 Owen Taylor + + * glib/gmain.c (g_main_context_unref_and_unlock): + When DISABLE_MEM_POOLS is set, loop through and free + the poll records explicitely, since g_mem_chunk_destroy() + won't do it. (#118121, Morten Welinder) + 2003-08-22 Samúel Jón Gunnarsson * is.po: Added "is" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 636afdc..ccf7305 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Mon Aug 25 12:17:20 2003 Owen Taylor + + * glib/gmain.c (g_main_context_unref_and_unlock): + When DISABLE_MEM_POOLS is set, loop through and free + the poll records explicitely, since g_mem_chunk_destroy() + won't do it. (#118121, Morten Welinder) + 2003-08-22 Samúel Jón Gunnarsson * is.po: Added "is" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 636afdc..ccf7305 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +Mon Aug 25 12:17:20 2003 Owen Taylor + + * glib/gmain.c (g_main_context_unref_and_unlock): + When DISABLE_MEM_POOLS is set, loop through and free + the poll records explicitely, since g_mem_chunk_destroy() + won't do it. (#118121, Morten Welinder) + 2003-08-22 Samúel Jón Gunnarsson * is.po: Added "is" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 636afdc..ccf7305 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Mon Aug 25 12:17:20 2003 Owen Taylor + + * glib/gmain.c (g_main_context_unref_and_unlock): + When DISABLE_MEM_POOLS is set, loop through and free + the poll records explicitely, since g_mem_chunk_destroy() + won't do it. (#118121, Morten Welinder) + 2003-08-22 Samúel Jón Gunnarsson * is.po: Added "is" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 636afdc..ccf7305 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Mon Aug 25 12:17:20 2003 Owen Taylor + + * glib/gmain.c (g_main_context_unref_and_unlock): + When DISABLE_MEM_POOLS is set, loop through and free + the poll records explicitely, since g_mem_chunk_destroy() + won't do it. (#118121, Morten Welinder) + 2003-08-22 Samúel Jón Gunnarsson * is.po: Added "is" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 636afdc..ccf7305 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Mon Aug 25 12:17:20 2003 Owen Taylor + + * glib/gmain.c (g_main_context_unref_and_unlock): + When DISABLE_MEM_POOLS is set, loop through and free + the poll records explicitely, since g_mem_chunk_destroy() + won't do it. (#118121, Morten Welinder) + 2003-08-22 Samúel Jón Gunnarsson * is.po: Added "is" to ALL_LINGUAS. diff --git a/glib/gmain.c b/glib/gmain.c index a3a9dc9..c838274 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -553,6 +553,26 @@ g_main_context_ref (GMainContext *context) UNLOCK_CONTEXT (context); } +/* If DISABLE_MEM_POOLS is defined, then freeing the + * mem chunk won't free the records, so we have to + * do it manually. The conditionalization here is + * an optimization; g_mem_chunk_free() is a no-op + * when DISABLE_MEM_POOLS is set. + */ +#ifdef DISABLE_MEM_POOLS +static void +poll_rec_list_free (GMainContext *context, + GPollRec *list) +{ + while (list) + { + GPollRec *tmp_rec = list; + list = list->next; + g_chunk_free (tmp_rec, context->poll_chunk); + } +} +#endif /* DISABLE_MEM_POOLS */ + static void g_main_context_unref_and_unlock (GMainContext *context) { @@ -581,7 +601,12 @@ g_main_context_unref_and_unlock (GMainContext *context) g_ptr_array_free (context->pending_dispatches, TRUE); g_free (context->cached_poll_array); - + +#ifdef DISABLE_MEM_POLLS + poll_rec_list_free (context, context->poll_records); + poll_rec_list_free (context, context->poll_free_list); +#endif /* DISABLE_MEM_POOLS */ + if (context->poll_chunk) g_mem_chunk_destroy (context->poll_chunk); -- 2.7.4