#include "lfstack.h" void stack_init(Stack* stack, void (*destroy)(void* data)) { ll_init(stack, destroy); } void stack_destroy(Stack* stack) { ll_destroy(stack); } int stack_push(Stack* stack, void *data) { if (stack->size == 0) { return ll_ins_next(stack, NULL, data); } else { return ll_ins_next(stack, stack->tail, data); } } void *stack_peek(Stack *stack) { return stack->tail == NULL ? NULL : stack->tail->data; } int stack_pop(Stack *stack, void **data) { return ll_remove(stack, stack->tail, data); }