fixed bugs that were keeping track of stack's length
This commit is contained in:
parent
cdaef08013
commit
a283b85767
|
@ -25,7 +25,7 @@ typedef struct Stack {
|
||||||
Stack* new_stack() {
|
Stack* new_stack() {
|
||||||
Stack* s = malloc(sizeof(Stack));
|
Stack* s = malloc(sizeof(Stack));
|
||||||
s->head = NULL;
|
s->head = NULL;
|
||||||
s->head = 0;
|
s->len = 0;
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,9 +57,12 @@ int pop(Stack* stack) {
|
||||||
Node* node = stack->head;
|
Node* node = stack->head;
|
||||||
int node_val = node->value;
|
int node_val = node->value;
|
||||||
stack->head = node->prev;
|
stack->head = node->prev;
|
||||||
|
stack->len--;
|
||||||
free(node);
|
free(node);
|
||||||
return (node_val);
|
return (node_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (-9999);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct IntBinaryNode {
|
typedef struct IntBinaryNode {
|
||||||
|
@ -70,6 +73,8 @@ typedef struct IntBinaryNode {
|
||||||
|
|
||||||
IntBinaryNode* new_int_binary_node(int value) {
|
IntBinaryNode* new_int_binary_node(int value) {
|
||||||
IntBinaryNode* n = malloc(sizeof(IntBinaryNode));
|
IntBinaryNode* n = malloc(sizeof(IntBinaryNode));
|
||||||
|
n->left = NULL;
|
||||||
|
n->right = NULL;
|
||||||
n->value = value;
|
n->value = value;
|
||||||
|
|
||||||
return (n);
|
return (n);
|
||||||
|
|
Loading…
Reference in New Issue