Skip to content

Instantly share code, notes, and snippets.



Last active Jul 15, 2019
What would you like to do?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "include/engine/stack.h"
#include "include/engine/mem.h"
void stack_init(CB_STACK **elem, void *data)
CB_STACK *n_element = NULL;
n_element = malloc(sizeof(CB_STACK));
n_element->next = NULL;
n_element->prev = NULL;
n_element->element = data;
n_element->count = 0;
*elem = n_element;
void *stack_first_element(CB_STACK **stack)
if( (*stack) != NULL){
return (*stack)->element;
return NULL;
void stack_add_elem(CB_STACK **stack, void *e){
CB_STACK *n_stack = NULL;
if( (*stack)->next == NULL){
n_stack = malloc(sizeof(CB_STACK));
stack_init(&n_stack, e);
(*stack)->next = n_stack;
(*stack) = (*stack)->next;
void *stack_next(CB_STACK **elem){
if((*elem)->next == NULL ){
return (*elem)->element;
*elem = (*elem)->next;
return (*elem)->element;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.