function pop is done
This commit is contained in:
@@ -22,7 +22,12 @@ return newNode;
|
||||
// freed by caller.)
|
||||
StackNode *pop(StackNode *stack)
|
||||
{
|
||||
if (stack == NULL)
|
||||
return NULL;
|
||||
|
||||
StackNode *next = stack->next;
|
||||
free(stack);
|
||||
return next;
|
||||
}
|
||||
|
||||
// Returns the data of the top element.
|
||||
@@ -30,10 +35,7 @@ void *top(StackNode *stack)
|
||||
{
|
||||
if (stack == NULL)
|
||||
return NULL;
|
||||
|
||||
StackNode *next = stack->next;
|
||||
free(stack);
|
||||
return next;
|
||||
return stack->data;
|
||||
}
|
||||
|
||||
// Clears stack and releases all memory.
|
||||
|
||||
Reference in New Issue
Block a user