#include "stack.h" #include StackNode *push(StackNode *stack, void *data) { if (data == NULL) return stack; StackNode *newnode = malloc(sizeof(StackNode)); if (newnode == NULL) return stack; newnode->data = data; newnode->next = stack; return newnode; } StackNode *pop(StackNode *stack) { if (stack == NULL) return stack; StackNode *newtop = stack->next; free(stack); return newtop; } void *top(StackNode *stack) { if (stack == NULL) return NULL; return stack->data; } void clearStack(StackNode *stack) { while (stack != NULL) { stack = pop(stack); // pop returnt newtop; } }