From f0aa621e6913486a55b9f7be15f12b2325937d75 Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Sat, 3 Apr 2010 22:12:42 -0300 Subject: [PATCH] Added pop() and function prototypes. --- lib/stack.c | 12 ++++++++++++ lib/stack.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/lib/stack.c b/lib/stack.c index d57fd96..53a9aaa 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -43,3 +43,15 @@ void push(struct stack *stack, struct card *card) { stack = new_stack; } } + +struct stack *pop(struct stack *stack) { + struct stack *popped_entry = NULL; + + if(!empty(stack)) { + popped_entry = stack; + popped_entry = NULL; + stack = stack->next; + } + + return(popped_entry); +} diff --git a/lib/stack.h b/lib/stack.h index 72daa6f..abb35b4 100644 --- a/lib/stack.h +++ b/lib/stack.h @@ -6,4 +6,10 @@ struct stack { struct stack *next; }; +struct stack *initialize_stack(); +bool empty(struct stack *); +int length(struct stack *); +void push(struct stack *, struct card *); +struct stack *pop(struct stack *); + #endif