Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GI.GLib.Structs.TrashStack
Description
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.
Synopsis
- newtype TrashStack = TrashStack (ManagedPtr TrashStack)
- newZeroTrashStack :: MonadIO m => m TrashStack
- trashStackHeight :: (HasCallStack, MonadIO m) => TrashStack -> m Word32
- trashStackPeek :: (HasCallStack, MonadIO m) => TrashStack -> m (Ptr ())
- trashStackPop :: (HasCallStack, MonadIO m) => TrashStack -> m (Ptr ())
- trashStackPush :: (HasCallStack, MonadIO m) => TrashStack -> Ptr () -> m ()
- clearTrashStackNext :: MonadIO m => TrashStack -> m ()
- getTrashStackNext :: MonadIO m => TrashStack -> m (Maybe TrashStack)
- setTrashStackNext :: MonadIO m => TrashStack -> Ptr TrashStack -> m ()
Exported types
newtype TrashStack Source #
Memory-managed wrapper type.
Constructors
TrashStack (ManagedPtr TrashStack) |
Instances
Eq TrashStack Source # | |
Defined in GI.GLib.Structs.TrashStack | |
BoxedPtr TrashStack Source # | |
Defined in GI.GLib.Structs.TrashStack | |
CallocPtr TrashStack Source # | |
Defined in GI.GLib.Structs.TrashStack Methods boxedPtrCalloc :: IO (Ptr TrashStack) | |
ManagedPtrNewtype TrashStack Source # | |
Defined in GI.GLib.Structs.TrashStack Methods toManagedPtr :: TrashStack -> ManagedPtr TrashStack | |
tag ~ 'AttrSet => Constructible TrashStack tag Source # | |
Defined in GI.GLib.Structs.TrashStack Methods new :: MonadIO m => (ManagedPtr TrashStack -> TrashStack) -> [AttrOp TrashStack tag] -> m TrashStack |
newZeroTrashStack :: MonadIO m => m TrashStack Source #
Construct a TrashStack
struct initialized to zero.
Methods
height
Arguments
:: (HasCallStack, MonadIO m) | |
=> TrashStack |
|
-> m Word32 | Returns: the height of the stack |
Deprecated: (Since version 2.48)tTrashStack
is deprecated without replacement
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.
peek
Arguments
:: (HasCallStack, MonadIO m) | |
=> TrashStack |
|
-> m (Ptr ()) | Returns: the element at the top of the stack |
Deprecated: (Since version 2.48)tTrashStack
is deprecated without replacement
Returns the element at the top of a TrashStack
which may be Nothing
.
pop
Arguments
:: (HasCallStack, MonadIO m) | |
=> TrashStack |
|
-> m (Ptr ()) | Returns: the element at the top of the stack |
Deprecated: (Since version 2.48)tTrashStack
is deprecated without replacement
Pops a piece of memory off a TrashStack
.
push
Arguments
:: (HasCallStack, MonadIO m) | |
=> TrashStack |
|
-> Ptr () |
|
-> m () |
Deprecated: (Since version 2.48)tTrashStack
is deprecated without replacement
Pushes a piece of memory onto a TrashStack
.
Properties
next
pointer to the previous element of the stack,
gets stored in the first sizeof (gpointer)
bytes of the element
clearTrashStackNext :: MonadIO m => TrashStack -> m () Source #
Set the value of the “next
” field to Nothing
.
When overloading is enabled, this is equivalent to
clear
#next
getTrashStackNext :: MonadIO m => TrashStack -> m (Maybe TrashStack) Source #
Get the value of the “next
” field.
When overloading is enabled, this is equivalent to
get
trashStack #next
setTrashStackNext :: MonadIO m => TrashStack -> Ptr TrashStack -> m () Source #
Set the value of the “next
” field.
When overloading is enabled, this is equivalent to
set
trashStack [ #next:=
value ]