diff options
Diffstat (limited to 'eglib/src/gqueue.c')
-rw-r--r-- | eglib/src/gqueue.c | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/eglib/src/gqueue.c b/eglib/src/gqueue.c index 2eedbf6f9f3..fb7083fc6b9 100644 --- a/eglib/src/gqueue.c +++ b/eglib/src/gqueue.c @@ -3,7 +3,6 @@ * * Author: * Duncan Mak (duncan@novell.com) - * Gonzalo Paniagua Javier (gonzalo@novell.com) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -24,7 +23,7 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * Copyright (c) 2006-2009 Novell, Inc. + * (C) 2006 Novell, Inc. * */ @@ -34,23 +33,19 @@ gpointer g_queue_pop_head (GQueue *queue) { - gpointer result; - GList *old_head; + gpointer head = NULL; - if (!queue || queue->length == 0) - return NULL; + if (queue->length != 0){ + GList *old_head; - result = queue->head->data; - old_head = queue->head; - queue->head = old_head->next; - g_list_free_1 (old_head); + old_head = queue->head; + head = old_head->data; + queue->head = old_head->next; + queue->length--; + g_list_free_1 (old_head); + } - if (--queue->length) - queue->head->prev = NULL; - else - queue->tail = NULL; - - return result; + return head; } gboolean @@ -76,24 +71,13 @@ g_queue_push_head (GQueue *queue, gpointer head) queue->length ++; } -void -g_queue_push_tail (GQueue *queue, gpointer data) -{ - if (!queue) - return; - - queue->tail = g_list_append (queue->tail, data); - if (queue->head == NULL) - queue->head = queue->tail; - else - queue->tail = queue->tail->next; - queue->length++; -} - GQueue * g_queue_new (void) { - return g_new0 (GQueue, 1); + GQueue *queue = g_new0 (GQueue, 1); + queue->length = 0; + + return queue; } void |