-
-
Save ibeauregard/1bd25a2e47b99ab081107c6a130fb170 to your computer and use it in GitHub Desktop.
Introduce the destructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* int_stack.h */ | |
//... | |
// Other function declarations | |
void delete_stack(IntStack** stack); | |
/* main.c */ | |
#include "int_stack.h" | |
//... | |
int main() | |
{ | |
//... | |
delete_stack(&stack); | |
return 0; | |
} | |
/* int_stack.c */ | |
#include "int_stack.h" | |
//... | |
void delete_stack(IntStack** stack) | |
{ | |
while (!is_empty_stack(*stack)) { | |
pop_stack(*stack); | |
} | |
free(*stack); *stack = NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment