Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Astack





The AStack module provides a stack container which is fully built on the program stack.

By being fully on the program stack -which means malloc is never called- an AStack instance is automatically destroyed when you leave the function in which it was built.

This container must be used with care:

The Astack module is only available on systems that provide an alloca function.

The astack module header is lapin/container/astack.h.

typedef struct s_bunny_astack
{
     const size_t length;
     const void * const * const top;

} t‌_‌b‌u‌n‌n‌y‌_‌a‌s‌t‌a‌c‌k;

Description

     This structure is the main data of the AStack container.

     This type cannot be declared on stack. It must be created by a call to b‌u‌n‌n‌y‌_‌n‌e‌w‌_‌a‌s‌t‌a‌c‌k.

Attributes

  • const size_t length:
         The amount of elements in the AStack container.
  • const void * const * const * top:
         A pointer to a node containing the first element of the AStack container, and the address of its following element if there is one. This attribute is NULL if there is no element inside the AStack.


INDEX

typedef struct s_bunny_astack_node
{
     void *data;
     struct s_bunny_astack_node *next;

} t‌_‌b‌u‌n‌n‌y‌_‌a‌s‌t‌a‌c‌k‌_‌n‌o‌d‌e;

Description

     This structure is the node in which every single data is referenced inside the stack.
This type is an inside type of the Astack module and should not be created by you.

Attributes

  • void *data:
         A pointer to a stored data.
  • struct s_bunny_astack_node *next:
         The node following the current one or NULL if there is none.


INDEX


Description

     Create an Astack.

Return value

  • The function returns the address of the created Astack.
    This function cannot fail without crashing your program by stack overflow.


INDEX

k

Description

     Return the amount of elements inside the Astack container.

Parameters


Return value

  • This function returns the amount of elements inside the Astack container.


INDEX


Description

     Return if the sent Astack container is empty.

Parameters


Return value

  • This function returns true if the sent Astack is empty.


INDEX


Description

     Return the element that is on top of the sent Astack.

Parameters


Return value

  • This function returns the top element of the sent Astack or NULL if there is none.


INDEX


Description

     Push at the top of the Astack the sent data.

Parameters




INDEX


Description

     Remove the top element from the sent Astack.
Do not attempt to pop an empty stack!

Parameters




INDEX