Fix memory leak
This commit is contained in:
parent
b7c0451cd2
commit
eca8a60141
|
@ -120,6 +120,10 @@ int parse(char *s, STACK* stack) {
|
|||
|
||||
int main(int argc, char **argv) {
|
||||
STACK* operands = init_stack(argc);
|
||||
if (operands == NULL) {
|
||||
fprintf(stderr, "Error creating operand stack.\n");
|
||||
return(2);
|
||||
}
|
||||
int error;
|
||||
while(*++argv) {
|
||||
error = parse(*argv, operands);
|
||||
|
@ -131,6 +135,7 @@ int main(int argc, char **argv) {
|
|||
int i;
|
||||
printf("Stack status:\n");
|
||||
for (i = (operands -> cnt); i > 0; i--) printf("%f\n", pop(operands));
|
||||
destroy_stack(operands);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue