#include "glib.h"
#include "galias.h"
-
-G_LOCK_DEFINE_STATIC (queue_memchunk);
-static GMemChunk *queue_memchunk = NULL;
-static GTrashStack *free_queue_nodes = NULL;
-
/**
* g_queue_new:
*
GQueue*
g_queue_new (void)
{
- GQueue *queue;
-
- G_LOCK (queue_memchunk);
- queue = g_trash_stack_pop (&free_queue_nodes);
-
- if (!queue)
- {
- if (!queue_memchunk)
- queue_memchunk = g_mem_chunk_new ("GLib GQueue chunk",
- sizeof (GQueue),
- sizeof (GQueue) * 128,
- G_ALLOC_ONLY);
- queue = g_chunk_new (GQueue, queue_memchunk);
- }
- G_UNLOCK (queue_memchunk);
-
- queue->head = NULL;
- queue->tail = NULL;
- queue->length = 0;
-
- return queue;
+ return g_slice_new0 (GQueue);
}
/**
g_return_if_fail (queue != NULL);
g_list_free (queue->head);
-
-#ifdef ENABLE_GC_FRIENDLY
- queue->head = NULL;
- queue->tail = NULL;
-#endif /* ENABLE_GC_FRIENDLY */
-
- G_LOCK (queue_memchunk);
- g_trash_stack_push (&free_queue_nodes, queue);
- G_UNLOCK (queue_memchunk);
+ g_slice_free (GQueue, queue);
}
/**
* Finds an element in a #GQueue, using a supplied function to find the
* desired element. It iterates over the queue, calling the given function
* which should return 0 when the desired element is found. The function
- * takes two gconstpointer arguments, the #GQueue element's data and the
- * given user data.
+ * takes two gconstpointer arguments, the #GQueue element's data as the
+ * first argument and the given user data as the second argument.
*
* Return value: The found link, or %NULL if it wasn't found
*
* called with two elements of the @queue and @user_data. It should
* return 0 if the elements are equal, a negative value if the first
* element comes before the second, and a positive value if the second
- * element comes after the first.
+ * element comes before the first.
* @user_data: user data passed to @func.
*
* Inserts @data into @queue using @func to determine the new position.