From 722aecd6dcaa9e141f0088640a877683846a6e85 Mon Sep 17 00:00:00 2001 From: ergz Date: Fri, 30 Jun 2023 07:46:20 -0700 Subject: [PATCH] change next to prev, just makes more sense --- c/stack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c/stack.c b/c/stack.c index a1e34e7..2ec2106 100644 --- a/c/stack.c +++ b/c/stack.c @@ -17,7 +17,7 @@ pop: len = 0 /[A]/ typedef struct Node { int value; - struct Node* next; + struct Node* prev; } Node; typedef struct Stack { @@ -28,7 +28,7 @@ typedef struct Stack { Node* new_node(int value) { Node* n = malloc(sizeof(Node)); n->value = value; - n->next = NULL; + n->prev = NULL; return (n); } @@ -47,7 +47,7 @@ bool pop(Stack* s) { if (s->length == 1) { s->head = NULL; } else { - s->head = n->next; + s->head = n->prev; } free(n); s->length--; @@ -67,7 +67,7 @@ void push(Stack* s, Node* n) { s->length++; } else { // make the old head point to what will be the new head - n->next = s->head; + n->prev = s->head; // make the head point to n now s->head = n; s->length++;