-
-
Save ibeauregard/5c006a21ae0f47a23094c3980f557a33 to your computer and use it in GitHub Desktop.
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.c */ | |
#include "int_stack.h" | |
typedef struct int_node IntNode; | |
struct internals { | |
IntNode* top; | |
}; | |
// ... | |
IntStack* new_stack() | |
{ | |
IntStack* this = malloc(sizeof (IntStack)); | |
this->_internals = malloc(sizeof (struct internals)); | |
this->_internals->top = NULL; | |
// Function pointer assignments | |
return this; | |
} | |
// ... | |
void push(IntStack* this, int value) | |
{ | |
IntNode* pushed = malloc(sizeof (IntNode)); | |
pushed->value = value; | |
pushed->next = this->_internals->top; // top is not tied directly to this anymore | |
this->_internals->top = pushed; | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment