45
43
overhead, since the stack pointers can be stored inside the memory chunks.
48
There is no function to create a <link linkend="GTrashStack"><type>GTrashStack</type></link>. A <link linkend="NULL:CAPS"><literal>NULL</literal></link> <link linkend="GTrashStack"><type>GTrashStack</type></link>*
46
There is no function to create a <link linkend="GTrashStack"><type>GTrashStack</type></link>. A <link linkend="NULL--CAPS"><literal>NULL</literal></link> <link linkend="GTrashStack"><type>GTrashStack</type></link>*
49
47
is a perfectly valid empty stack.
53
<refsect1 role="details">
51
<refsect1 id="glib-Trash-Stacks.details" role="details">
54
52
<title role="details.title">Details</title>
56
<title><anchor id="GTrashStack" role="struct"/>GTrashStack</title>
57
<indexterm><primary>GTrashStack</primary></indexterm><programlisting>typedef struct {
53
<refsect2 id="GTrashStack" role="struct">
54
<title>GTrashStack</title>
55
<indexterm zone="GTrashStack"><primary sortas="GTrashStack">GTrashStack</primary></indexterm><programlisting>typedef struct {
63
61
is cast to a <structname>GTrashStack*</structname>.
64
62
</para><variablelist role="struct">
66
<term><link linkend="GTrashStack">GTrashStack</link> *<structfield>next</structfield>;</term>
64
<term><link linkend="GTrashStack">GTrashStack</link> *<structfield>next</structfield>;</term>
67
65
<listitem><simpara>pointer to the previous element of the stack,
68
66
gets stored in the first <literal>sizeof (gpointer)</literal>
69
67
bytes of the element.
71
68
</simpara></listitem>
73
70
</variablelist></refsect2>
75
<title><anchor id="g-trash-stack-push" role="function"/>g_trash_stack_push ()</title>
76
<indexterm><primary>g_trash_stack_push</primary></indexterm><programlisting><link linkend="void">void</link> g_trash_stack_push (<link linkend="GTrashStack">GTrashStack</link> **stack_p,
71
<refsect2 id="g-trash-stack-push" role="function">
72
<title>g_trash_stack_push ()</title>
73
<indexterm zone="g-trash-stack-push"><primary sortas="g_trash_stack_push">g_trash_stack_push</primary></indexterm><programlisting><link linkend="void">void</link> g_trash_stack_push (<link linkend="GTrashStack">GTrashStack</link> **stack_p,
77
74
<link linkend="gpointer">gpointer</link> data_p);</programlisting>
79
76
Pushes a piece of memory onto a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
80
77
</para><variablelist role="params">
81
<varlistentry><term><parameter>stack_p</parameter> :</term>
78
<varlistentry><term><parameter>stack_p</parameter> :</term>
82
79
<listitem><simpara>a pointer to a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
83
80
</simpara></listitem></varlistentry>
84
<varlistentry><term><parameter>data_p</parameter> :</term>
81
<varlistentry><term><parameter>data_p</parameter> :</term>
85
82
<listitem><simpara>the piece of memory to push on the stack.
88
83
</simpara></listitem></varlistentry>
89
84
</variablelist></refsect2>
91
<title><anchor id="g-trash-stack-pop" role="function"/>g_trash_stack_pop ()</title>
92
<indexterm><primary>g_trash_stack_pop</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link> g_trash_stack_pop (<link linkend="GTrashStack">GTrashStack</link> **stack_p);</programlisting>
85
<refsect2 id="g-trash-stack-pop" role="function">
86
<title>g_trash_stack_pop ()</title>
87
<indexterm zone="g-trash-stack-pop"><primary sortas="g_trash_stack_pop">g_trash_stack_pop</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link> g_trash_stack_pop (<link linkend="GTrashStack">GTrashStack</link> **stack_p);</programlisting>
94
89
Pops a piece of memory off a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
95
90
</para><variablelist role="params">
96
<varlistentry><term><parameter>stack_p</parameter> :</term>
91
<varlistentry><term><parameter>stack_p</parameter> :</term>
97
92
<listitem><simpara>a pointer to a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
98
93
</simpara></listitem></varlistentry>
99
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>the element at the top of the stack.
94
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>the element at the top of the stack.
102
95
</simpara></listitem></varlistentry>
103
96
</variablelist></refsect2>
105
<title><anchor id="g-trash-stack-peek" role="function"/>g_trash_stack_peek ()</title>
106
<indexterm><primary>g_trash_stack_peek</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link> g_trash_stack_peek (<link linkend="GTrashStack">GTrashStack</link> **stack_p);</programlisting>
97
<refsect2 id="g-trash-stack-peek" role="function">
98
<title>g_trash_stack_peek ()</title>
99
<indexterm zone="g-trash-stack-peek"><primary sortas="g_trash_stack_peek">g_trash_stack_peek</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link> g_trash_stack_peek (<link linkend="GTrashStack">GTrashStack</link> **stack_p);</programlisting>
108
Returns the element at the top of a <link linkend="GTrashStack"><type>GTrashStack</type></link> which may be <link linkend="NULL:CAPS"><literal>NULL</literal></link>.
101
Returns the element at the top of a <link linkend="GTrashStack"><type>GTrashStack</type></link> which may be <link linkend="NULL--CAPS"><literal>NULL</literal></link>.
109
102
</para><variablelist role="params">
110
<varlistentry><term><parameter>stack_p</parameter> :</term>
103
<varlistentry><term><parameter>stack_p</parameter> :</term>
111
104
<listitem><simpara>a pointer to a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
112
105
</simpara></listitem></varlistentry>
113
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>the element at the top of the stack.
106
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>the element at the top of the stack.
116
107
</simpara></listitem></varlistentry>
117
108
</variablelist></refsect2>
119
<title><anchor id="g-trash-stack-height" role="function"/>g_trash_stack_height ()</title>
120
<indexterm><primary>g_trash_stack_height</primary></indexterm><programlisting><link linkend="guint">guint</link> g_trash_stack_height (<link linkend="GTrashStack">GTrashStack</link> **stack_p);</programlisting>
109
<refsect2 id="g-trash-stack-height" role="function">
110
<title>g_trash_stack_height ()</title>
111
<indexterm zone="g-trash-stack-height"><primary sortas="g_trash_stack_height">g_trash_stack_height</primary></indexterm><programlisting><link linkend="guint">guint</link> g_trash_stack_height (<link linkend="GTrashStack">GTrashStack</link> **stack_p);</programlisting>
122
113
Returns the height of a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
123
114
Note that execution of this function is of O(N) complexity
124
115
where N denotes the number of items on the stack.
125
116
</para><variablelist role="params">
126
<varlistentry><term><parameter>stack_p</parameter> :</term>
117
<varlistentry><term><parameter>stack_p</parameter> :</term>
127
118
<listitem><simpara>a pointer to a <link linkend="GTrashStack"><type>GTrashStack</type></link>.
128
119
</simpara></listitem></varlistentry>
129
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>the height of the stack.
120
<varlistentry><term><emphasis>Returns</emphasis> :</term><listitem><simpara>the height of the stack.
132
121
</simpara></listitem></varlistentry>
133
122
</variablelist></refsect2>