Skip to content

GLib.TrashStack

record (struct)

:::warning Deprecated since 2.48 This API is deprecated. :::

A GTrashStack is an efficient way to keep a stack of unused allocated memory chunks. Each memory chunk is required to be large enough to hold a gpointer. This allows the stack to be maintained without any space overhead, since the stack pointers can be stored inside the memory chunks.

There is no function to create a GTrashStack. A NULL GTrashStack* is a perfectly valid empty stack.

Each piece of memory that is pushed onto the stack is cast to a GTrashStack*.

There is no longer any good reason to use GTrashStack. If you have extra pieces of memory, free() them and allocate them again later.

Static functions

height

@staticmethod
def height(stack_p: TrashStack) -> int

:::warning Deprecated since 2.48 This API is deprecated. :::

Returns the height of a TrashStack.

Note that execution of this function is of O(N) complexity where N denotes the number of items on the stack.

Parameters:

peek

@staticmethod
def peek(stack_p: TrashStack) -> int | None

:::warning Deprecated since 2.48 This API is deprecated. :::

Returns the element at the top of a TrashStack which may be None.

Parameters:

pop

@staticmethod
def pop(stack_p: TrashStack) -> int | None

:::warning Deprecated since 2.48 This API is deprecated. :::

Pops a piece of memory off a TrashStack.

Parameters:

push

@staticmethod
def push(stack_p: TrashStack, data_p: int) -> None

:::warning Deprecated since 2.48 This API is deprecated. :::

Pushes a piece of memory onto a TrashStack.

Parameters:

  • stack_p — a TrashStack
  • data_p — the piece of memory to push on the stack

Properties

next

next: TrashStack  # read/write