Move GTrashStack out of gutils.[hc]
[platform/upstream/glib.git] / glib / gtrashstack.c
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1998  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GLib Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include "config.h"
28
29 /**
30  * SECTION:trash_stack
31  * @title: Trash Stacks
32  * @short_description: maintain a stack of unused allocated memory chunks
33  *
34  * A #GTrashStack is an efficient way to keep a stack of unused allocated
35  * memory chunks. Each memory chunk is required to be large enough to hold
36  * a #gpointer. This allows the stack to be maintained without any space
37  * overhead, since the stack pointers can be stored inside the memory chunks.
38  *
39  * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
40  * is a perfectly valid empty stack.
41  */
42
43 /**
44  * GTrashStack:
45  * @next: pointer to the previous element of the stack,
46  *     gets stored in the first <literal>sizeof (gpointer)</literal>
47  *     bytes of the element
48  *
49  * Each piece of memory that is pushed onto the stack
50  * is cast to a <structname>GTrashStack*</structname>.
51  */
52
53 /**
54  * g_trash_stack_push:
55  * @stack_p: a #GTrashStack
56  * @data_p: the piece of memory to push on the stack
57  *
58  * Pushes a piece of memory onto a #GTrashStack.
59  */
60
61 /**
62  * g_trash_stack_pop:
63  * @stack_p: a #GTrashStack
64  *
65  * Pops a piece of memory off a #GTrashStack.
66  *
67  * Returns: the element at the top of the stack
68  */
69
70 /**
71  * g_trash_stack_peek:
72  * @stack_p: a #GTrashStack
73  *
74  * Returns the element at the top of a #GTrashStack
75  * which may be %NULL.
76  *
77  * Returns: the element at the top of the stack
78  */
79
80 /**
81  * g_trash_stack_height:
82  * @stack_p: a #GTrashStack
83  *
84  * Returns the height of a #GTrashStack.
85  *
86  * Note that execution of this function is of O(N) complexity
87  * where N denotes the number of items on the stack.
88  *
89  * Returns: the height of the stack
90  */
91
92 #define G_IMPLEMENT_INLINES 1
93 #define __G_TRASH_STACK_C__
94 #include "gtrashstack.h"