function top is done
This commit is contained in:
parent
bc6ec040b7
commit
69f44a5aa0
5
stack.c
5
stack.c
@ -28,7 +28,12 @@ StackNode *pop(StackNode *stack)
|
|||||||
// Returns the data of the top element.
|
// Returns the data of the top element.
|
||||||
void *top(StackNode *stack)
|
void *top(StackNode *stack)
|
||||||
{
|
{
|
||||||
|
if (stack == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
StackNode *next = stack->next;
|
||||||
|
free(stack);
|
||||||
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears stack and releases all memory.
|
// Clears stack and releases all memory.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user