1<!-- ##### SECTION Title ##### --> 2Trash Stacks 3 4<!-- ##### SECTION Short_Description ##### --> 5maintain a stack of unused allocated memory chunks 6 7<!-- ##### SECTION Long_Description ##### --> 8<para> 9A #GTrashStack is an efficient way to keep a stack of unused allocated 10memory chunks. Each memory chunk is required to be large enough to hold 11a #gpointer. This allows the stack to be maintained without any space 12overhead, since the stack pointers can be stored inside the memory chunks. 13</para> 14<para> 15There is no function to create a #GTrashStack. A %NULL #GTrashStack* 16is a perfectly valid empty stack. 17</para> 18 19<!-- ##### SECTION See_Also ##### --> 20<para> 21 22</para> 23 24<!-- ##### SECTION Stability_Level ##### --> 25 26 27<!-- ##### STRUCT GTrashStack ##### --> 28<para> 29Each piece of memory that is pushed onto the stack 30is cast to a <structname>GTrashStack*</structname>. 31</para> 32 33@next: pointer to the previous element of the stack, 34gets stored in the first <literal>sizeof (gpointer)</literal> 35bytes of the element. 36 37<!-- ##### FUNCTION g_trash_stack_push ##### --> 38<para> 39Pushes a piece of memory onto a #GTrashStack. 40</para> 41 42@stack_p: a pointer to a #GTrashStack. 43@data_p: the piece of memory to push on the stack. 44 45 46<!-- ##### FUNCTION g_trash_stack_pop ##### --> 47<para> 48Pops a piece of memory off a #GTrashStack. 49</para> 50 51@stack_p: a pointer to a #GTrashStack. 52@Returns: the element at the top of the stack. 53 54 55<!-- ##### FUNCTION g_trash_stack_peek ##### --> 56<para> 57Returns the element at the top of a #GTrashStack which may be %NULL. 58</para> 59 60@stack_p: a pointer to a #GTrashStack. 61@Returns: the element at the top of the stack. 62 63 64<!-- ##### FUNCTION g_trash_stack_height ##### --> 65<para> 66Returns the height of a #GTrashStack. 67Note that execution of this function is of O(N) complexity 68where N denotes the number of items on the stack. 69</para> 70 71@stack_p: a pointer to a #GTrashStack. 72@Returns: the height of the stack. 73 74 75