use standard_calloc to allocate the profile_data. (#335209, Chris Wilson)

2006-03-20  Matthias Clasen  <mclasen@redhat.com>

        * glib/gmem.c (profiler_log): use standard_calloc to allocate
        the profile_data.  (#335209, Chris Wilson)

        * glib/gmain.c (g_main_context_unref): Avoid a deadlock.
        (#335207, Chris Wilson)

        Minor optimizations (#335216, Chris Wilson):

        * glib/gasyncqueue.c (g_async_queue_pop_intern_unlocked): Use
        g_queue_peek_tail_link instead of g_queue_peek_tail.

        * glib/glist.c:
        * glib/gslist.c: Avoid some memset calls.
This commit is contained in:
Matthias Clasen 2006-03-20 18:43:32 +00:00 committed by Matthias Clasen
parent 56b06e14dc
commit d0ee63840c
8 changed files with 106 additions and 45 deletions

View File

@ -1,3 +1,19 @@
2006-03-20 Matthias Clasen <mclasen@redhat.com>
* glib/gmem.c (profiler_log): use standard_calloc to allocate
the profile_data. (#335209, Chris Wilson)
* glib/gmain.c (g_main_context_unref): Avoid a deadlock.
(#335207, Chris Wilson)
Minor optimizations (#335216, Chris Wilson):
* glib/gasyncqueue.c (g_async_queue_pop_intern_unlocked): Use
g_queue_peek_tail_link instead of g_queue_peek_tail.
* glib/glist.c:
* glib/gslist.c: Avoid some memset calls.
2006-03-19 Matthias Clasen <mclasen@redhat.com> 2006-03-19 Matthias Clasen <mclasen@redhat.com>
* MAINTAINERS: Add this, at the request of the GNOME sysadmin team. * MAINTAINERS: Add this, at the request of the GNOME sysadmin team.

View File

@ -1,3 +1,19 @@
2006-03-20 Matthias Clasen <mclasen@redhat.com>
* glib/gmem.c (profiler_log): use standard_calloc to allocate
the profile_data. (#335209, Chris Wilson)
* glib/gmain.c (g_main_context_unref): Avoid a deadlock.
(#335207, Chris Wilson)
Minor optimizations (#335216, Chris Wilson):
* glib/gasyncqueue.c (g_async_queue_pop_intern_unlocked): Use
g_queue_peek_tail_link instead of g_queue_peek_tail.
* glib/glist.c:
* glib/gslist.c: Avoid some memset calls.
2006-03-19 Matthias Clasen <mclasen@redhat.com> 2006-03-19 Matthias Clasen <mclasen@redhat.com>
* MAINTAINERS: Add this, at the request of the GNOME sysadmin team. * MAINTAINERS: Add this, at the request of the GNOME sysadmin team.

View File

@ -1,3 +1,19 @@
2006-03-20 Matthias Clasen <mclasen@redhat.com>
* glib/gmem.c (profiler_log): use standard_calloc to allocate
the profile_data. (#335209, Chris Wilson)
* glib/gmain.c (g_main_context_unref): Avoid a deadlock.
(#335207, Chris Wilson)
Minor optimizations (#335216, Chris Wilson):
* glib/gasyncqueue.c (g_async_queue_pop_intern_unlocked): Use
g_queue_peek_tail_link instead of g_queue_peek_tail.
* glib/glist.c:
* glib/gslist.c: Avoid some memset calls.
2006-03-19 Matthias Clasen <mclasen@redhat.com> 2006-03-19 Matthias Clasen <mclasen@redhat.com>
* MAINTAINERS: Add this, at the request of the GNOME sysadmin team. * MAINTAINERS: Add this, at the request of the GNOME sysadmin team.

View File

@ -313,12 +313,13 @@ g_async_queue_push_sorted_unlocked (GAsyncQueue *queue,
} }
static gpointer static gpointer
g_async_queue_pop_intern_unlocked (GAsyncQueue* queue, gboolean try, g_async_queue_pop_intern_unlocked (GAsyncQueue *queue,
gboolean try,
GTimeVal *end_time) GTimeVal *end_time)
{ {
gpointer retval; gpointer retval;
if (!g_queue_peek_tail (queue->queue)) if (!g_queue_peek_tail_link (queue->queue))
{ {
if (try) if (try)
return NULL; return NULL;
@ -329,18 +330,18 @@ g_async_queue_pop_intern_unlocked (GAsyncQueue* queue, gboolean try,
if (!end_time) if (!end_time)
{ {
queue->waiting_threads++; queue->waiting_threads++;
while (!g_queue_peek_tail (queue->queue)) while (!g_queue_peek_tail_link (queue->queue))
g_cond_wait(queue->cond, queue->mutex); g_cond_wait (queue->cond, queue->mutex);
queue->waiting_threads--; queue->waiting_threads--;
} }
else else
{ {
queue->waiting_threads++; queue->waiting_threads++;
while (!g_queue_peek_tail (queue->queue)) while (!g_queue_peek_tail_link (queue->queue))
if (!g_cond_timed_wait (queue->cond, queue->mutex, end_time)) if (!g_cond_timed_wait (queue->cond, queue->mutex, end_time))
break; break;
queue->waiting_threads--; queue->waiting_threads--;
if (!g_queue_peek_tail (queue->queue)) if (!g_queue_peek_tail_link (queue->queue))
return NULL; return NULL;
} }
} }

View File

@ -37,6 +37,7 @@
void g_list_push_allocator (gpointer dummy) { /* present for binary compat only */ } void g_list_push_allocator (gpointer dummy) { /* present for binary compat only */ }
void g_list_pop_allocator (void) { /* present for binary compat only */ } void g_list_pop_allocator (void) { /* present for binary compat only */ }
#define _g_list_alloc() g_slice_new (GList)
#define _g_list_alloc0() g_slice_new0 (GList) #define _g_list_alloc0() g_slice_new0 (GList)
#define _g_list_free1(list) g_slice_free (GList, list) #define _g_list_free1(list) g_slice_free (GList, list)
@ -65,8 +66,9 @@ g_list_append (GList *list,
GList *new_list; GList *new_list;
GList *last; GList *last;
new_list = _g_list_alloc0 (); new_list = _g_list_alloc ();
new_list->data = data; new_list->data = data;
new_list->next = NULL;
if (list) if (list)
{ {
@ -78,7 +80,10 @@ g_list_append (GList *list,
return list; return list;
} }
else else
{
new_list->prev = NULL;
return new_list; return new_list;
}
} }
GList* GList*
@ -87,19 +92,19 @@ g_list_prepend (GList *list,
{ {
GList *new_list; GList *new_list;
new_list = _g_list_alloc0 (); new_list = _g_list_alloc ();
new_list->data = data; new_list->data = data;
new_list->next = list;
if (list) if (list)
{ {
if (list->prev)
{
list->prev->next = new_list;
new_list->prev = list->prev; new_list->prev = list->prev;
} if (list->prev)
list->prev->next = new_list;
list->prev = new_list; list->prev = new_list;
new_list->next = list;
} }
else
new_list->prev = NULL;
return new_list; return new_list;
} }
@ -121,14 +126,11 @@ g_list_insert (GList *list,
if (!tmp_list) if (!tmp_list)
return g_list_append (list, data); return g_list_append (list, data);
new_list = _g_list_alloc0 (); new_list = _g_list_alloc ();
new_list->data = data; new_list->data = data;
if (tmp_list->prev)
{
tmp_list->prev->next = new_list;
new_list->prev = tmp_list->prev; new_list->prev = tmp_list->prev;
} if (tmp_list->prev)
tmp_list->prev->next = new_list;
new_list->next = tmp_list; new_list->next = tmp_list;
tmp_list->prev = new_list; tmp_list->prev = new_list;
@ -154,20 +156,18 @@ g_list_insert_before (GList *list,
{ {
GList *node; GList *node;
node = g_list_alloc (); node = _g_list_alloc ();
node->data = data; node->data = data;
if (sibling->prev)
{
node->prev = sibling->prev; node->prev = sibling->prev;
node->prev->next = node;
node->next = sibling; node->next = sibling;
sibling->prev = node; sibling->prev = node;
if (node->prev)
{
node->prev->next = node;
return list; return list;
} }
else else
{ {
node->next = sibling;
sibling->prev = node;
g_return_val_if_fail (sibling == list, node); g_return_val_if_fail (sibling == list, node);
return node; return node;
} }
@ -180,9 +180,10 @@ g_list_insert_before (GList *list,
while (last->next) while (last->next)
last = last->next; last = last->next;
last->next = g_list_alloc (); last->next = _g_list_alloc ();
last->next->data = data; last->next->data = data;
last->next->prev = last; last->next->prev = last;
last->next->next = NULL;
return list; return list;
} }
@ -310,18 +311,20 @@ g_list_copy (GList *list)
{ {
GList *last; GList *last;
new_list = _g_list_alloc0 (); new_list = _g_list_alloc ();
new_list->data = list->data; new_list->data = list->data;
new_list->prev = NULL;
last = new_list; last = new_list;
list = list->next; list = list->next;
while (list) while (list)
{ {
last->next = _g_list_alloc0 (); last->next = _g_list_alloc ();
last->next->prev = last; last->next->prev = last;
last = last->next; last = last->next;
last->data = list->data; last->data = list->data;
list = list->next; list = list->next;
} }
last->next = NULL;
} }
return new_list; return new_list;

View File

@ -627,7 +627,7 @@ g_main_context_unref (GMainContext *context)
while (source) while (source)
{ {
GSource *next = source->next; GSource *next = source->next;
g_source_destroy_internal (source, context, TRUE); g_source_destroy_internal (source, context, FALSE);
source = next; source = next;
} }

View File

@ -318,7 +318,7 @@ profiler_log (ProfilerJob job,
g_mutex_lock (gmem_profile_mutex); g_mutex_lock (gmem_profile_mutex);
if (!profile_data) if (!profile_data)
{ {
profile_data = standard_malloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])); profile_data = standard_calloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0]));
if (!profile_data) /* memory system kiddin' me, eh? */ if (!profile_data) /* memory system kiddin' me, eh? */
{ {
g_mutex_unlock (gmem_profile_mutex); g_mutex_unlock (gmem_profile_mutex);

View File

@ -38,6 +38,7 @@ void g_slist_push_allocator (gpointer dummy) { /* present for binary compat only
void g_slist_pop_allocator (void) { /* present for binary compat only */ } void g_slist_pop_allocator (void) { /* present for binary compat only */ }
#define _g_slist_alloc0() g_slice_new0 (GSList) #define _g_slist_alloc0() g_slice_new0 (GSList)
#define _g_slist_alloc() g_slice_new (GSList)
#define _g_slist_free1(slist) g_slice_free (GSList, slist) #define _g_slist_free1(slist) g_slice_free (GSList, slist)
GSList* GSList*
@ -65,8 +66,9 @@ g_slist_append (GSList *list,
GSList *new_list; GSList *new_list;
GSList *last; GSList *last;
new_list = _g_slist_alloc0 (); new_list = _g_slist_alloc ();
new_list->data = data; new_list->data = data;
new_list->next = NULL;
if (list) if (list)
{ {
@ -86,7 +88,7 @@ g_slist_prepend (GSList *list,
{ {
GSList *new_list; GSList *new_list;
new_list = _g_slist_alloc0 (); new_list = _g_slist_alloc ();
new_list->data = data; new_list->data = data;
new_list->next = list; new_list->next = list;
@ -107,11 +109,14 @@ g_slist_insert (GSList *list,
else if (position == 0) else if (position == 0)
return g_slist_prepend (list, data); return g_slist_prepend (list, data);
new_list = _g_slist_alloc0 (); new_list = _g_slist_alloc ();
new_list->data = data; new_list->data = data;
if (!list) if (!list)
{
new_list->next = NULL;
return new_list; return new_list;
}
prev_list = NULL; prev_list = NULL;
tmp_list = list; tmp_list = list;
@ -143,8 +148,9 @@ g_slist_insert_before (GSList *slist,
{ {
if (!slist) if (!slist)
{ {
slist = g_slist_alloc (); slist = _g_slist_alloc ();
slist->data = data; slist->data = data;
slist->next = NULL;
g_return_val_if_fail (sibling == NULL, slist); g_return_val_if_fail (sibling == NULL, slist);
return slist; return slist;
} }
@ -157,7 +163,7 @@ g_slist_insert_before (GSList *slist,
break; break;
if (!last) if (!last)
{ {
node = g_slist_alloc (); node = _g_slist_alloc ();
node->data = data; node->data = data;
node->next = slist; node->next = slist;
@ -165,7 +171,7 @@ g_slist_insert_before (GSList *slist,
} }
else else
{ {
node = g_slist_alloc (); node = _g_slist_alloc ();
node->data = data; node->data = data;
node->next = last->next; node->next = last->next;
last->next = node; last->next = node;
@ -302,17 +308,18 @@ g_slist_copy (GSList *list)
{ {
GSList *last; GSList *last;
new_list = _g_slist_alloc0 (); new_list = _g_slist_alloc ();
new_list->data = list->data; new_list->data = list->data;
last = new_list; last = new_list;
list = list->next; list = list->next;
while (list) while (list)
{ {
last->next = _g_slist_alloc0 (); last->next = _g_slist_alloc ();
last = last->next; last = last->next;
last->data = list->data; last->data = list->data;
list = list->next; list = list->next;
} }
last->next = NULL;
} }
return new_list; return new_list;
@ -478,8 +485,9 @@ g_slist_insert_sorted_real (GSList *list,
if (!list) if (!list)
{ {
new_list = _g_slist_alloc0 (); new_list = _g_slist_alloc ();
new_list->data = data; new_list->data = data;
new_list->next = NULL;
return new_list; return new_list;
} }
@ -493,12 +501,13 @@ g_slist_insert_sorted_real (GSList *list,
cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data); cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data);
} }
new_list = _g_slist_alloc0 (); new_list = _g_slist_alloc ();
new_list->data = data; new_list->data = data;
if ((!tmp_list->next) && (cmp > 0)) if ((!tmp_list->next) && (cmp > 0))
{ {
tmp_list->next = new_list; tmp_list->next = new_list;
new_list->next = NULL;
return list; return list;
} }