summaryrefslogtreecommitdiff
path: root/gqueue.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>1999-03-17 15:38:18 +0000
committerJeff Garzik <jgarzik@src.gnome.org>1999-03-17 15:38:18 +0000
commit05f42cc0e2e639effb95206d20d39070de3be0c7 (patch)
tree2f4f171bb95f146f920a9d32c9cf9882ee64eff0 /gqueue.c
parent771d71208598fc6bcc41972767cb4672ce70a9be (diff)
downloadglib-05f42cc0e2e639effb95206d20d39070de3be0c7.tar.gz
Add copyright, clean up code a bit.
1999-03-17 Jeff Garzik <jgarzik@pobox.com> * gstack.c, gqueue.c: Add copyright, clean up code a bit.
Diffstat (limited to 'gqueue.c')
-rw-r--r--gqueue.c150
1 files changed, 80 insertions, 70 deletions
diff --git a/gqueue.c b/gqueue.c
index 85e9b54b7..b516b2474 100644
--- a/gqueue.c
+++ b/gqueue.c
@@ -1,20 +1,21 @@
-/*
-* GQueue, opaque ADT with interface:
-
- q = g_queue_new ();
- count = g_queue_size (q);
-
- q_queue_push_front (q, data);
- q_queue_push_back (q, data);
- data = q_queue_pop_front (q);
- data = q_queue_pop_back (q);
- #define q_queue_push q_queue_push_back
- #define q_queue_pop q_queue_pop_front
-
- list = g_queue_get_list (q);
- #define g_queue_get_front g_queue_get_list
- list_end = g_queue_get_back (q);
-*/
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
#ifdef HAVE_CONFIG_H
@@ -41,11 +42,12 @@ g_queue_new (void)
void
g_queue_free (GQueue *q)
{
- if (q) {
- if (q->list)
- g_list_free (q->list);
- g_free (q);
- }
+ if (q)
+ {
+ if (q->list)
+ g_list_free (q->list);
+ g_free (q);
+ }
}
@@ -59,30 +61,32 @@ g_queue_get_size (GQueue *q)
void
g_queue_push_front (GQueue *q, gpointer data)
{
- if (q) {
- q->list = g_list_prepend (q->list, data);
+ if (q)
+ {
+ q->list = g_list_prepend (q->list, data);
- if (q->list_end == NULL)
- q->list_end = q->list;
+ if (q->list_end == NULL)
+ q->list_end = q->list;
- q->list_size++;
- }
+ q->list_size++;
+ }
}
void
g_queue_push_back (GQueue *q, gpointer data)
{
- if (q) {
- q->list_end = g_list_append (q->list_end, data);
+ if (q)
+ {
+ q->list_end = g_list_append (q->list_end, data);
- if (! q->list)
- q->list = q->list_end;
- else
- q->list_end = q->list_end->next;
+ if (! q->list)
+ q->list = q->list_end;
+ else
+ q->list_end = q->list_end->next;
- q->list_size++;
- }
+ q->list_size++;
+ }
}
@@ -91,25 +95,28 @@ g_queue_pop_front (GQueue *q)
{
gpointer data = NULL;
- if ((q) && (q->list)) {
- GList *node;
-
- node = q->list;
- data = node->data;
-
- if (! node->next) {
- q->list = q->list_end = NULL;
- q->list_size = 0;
- }
- else {
- q->list = node->next;
- q->list->prev = NULL;
- q->list_size--;
+ if ((q) && (q->list))
+ {
+ GList *node;
+
+ node = q->list;
+ data = node->data;
+
+ if (! node->next)
+ {
+ q->list = q->list_end = NULL;
+ q->list_size = 0;
+ }
+ else
+ {
+ q->list = node->next;
+ q->list->prev = NULL;
+ q->list_size--;
+ }
+
+ g_list_free_1 (node);
}
- g_list_free_1 (node);
- }
-
return data;
}
@@ -119,25 +126,28 @@ g_queue_pop_back (GQueue *q)
{
gpointer data = NULL;
- if ((q) && (q->list)) {
- GList *node;
-
- node = q->list_end;
- data = node->data;
-
- if (! node->prev) {
- q->list = q->list_end = NULL;
- q->list_size = 0;
- }
- else {
- q->list_end = node->prev;
- q->list_end->next = NULL;
- q->list_size--;
+ if ((q) && (q->list))
+ {
+ GList *node;
+
+ node = q->list_end;
+ data = node->data;
+
+ if (! node->prev)
+ {
+ q->list = q->list_end = NULL;
+ q->list_size = 0;
+ }
+ else
+ {
+ q->list_end = node->prev;
+ q->list_end->next = NULL;
+ q->list_size--;
+ }
+
+ g_list_free_1 (node);
}
- g_list_free_1 (node);
- }
-
return data;
}