glib-unix: add function to ensure an fd is sealed
[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, see <http://www.gnu.org/licenses/>.
16  */
17
18 /*
19  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
20  * file for a list of people on the GLib Team.  See the ChangeLog
21  * files for a list of changes.  These files are distributed with
22  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
23  */
24
25 #include "config.h"
26
27 /**
28  * SECTION:trash_stack
29  * @title: Trash Stacks
30  * @short_description: maintain a stack of unused allocated memory chunks
31  *
32  * A #GTrashStack is an efficient way to keep a stack of unused allocated
33  * memory chunks. Each memory chunk is required to be large enough to hold
34  * a #gpointer. This allows the stack to be maintained without any space
35  * overhead, since the stack pointers can be stored inside the memory chunks.
36  *
37  * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
38  * is a perfectly valid empty stack.
39  */
40
41 /**
42  * GTrashStack:
43  * @next: pointer to the previous element of the stack,
44  *     gets stored in the first `sizeof (gpointer)`
45  *     bytes of the element
46  *
47  * Each piece of memory that is pushed onto the stack
48  * is cast to a GTrashStack*.
49  */
50
51 /**
52  * g_trash_stack_push:
53  * @stack_p: a #GTrashStack
54  * @data_p: the piece of memory to push on the stack
55  *
56  * Pushes a piece of memory onto a #GTrashStack.
57  */
58
59 /**
60  * g_trash_stack_pop:
61  * @stack_p: a #GTrashStack
62  *
63  * Pops a piece of memory off a #GTrashStack.
64  *
65  * Returns: the element at the top of the stack
66  */
67
68 /**
69  * g_trash_stack_peek:
70  * @stack_p: a #GTrashStack
71  *
72  * Returns the element at the top of a #GTrashStack
73  * which may be %NULL.
74  *
75  * Returns: the element at the top of the stack
76  */
77
78 /**
79  * g_trash_stack_height:
80  * @stack_p: a #GTrashStack
81  *
82  * Returns the height of a #GTrashStack.
83  *
84  * Note that execution of this function is of O(N) complexity
85  * where N denotes the number of items on the stack.
86  *
87  * Returns: the height of the stack
88  */
89
90 #define G_IMPLEMENT_INLINES 1
91 #define __G_TRASH_STACK_C__
92 #include "gtrashstack.h"