Skip to content

Instantly share code, notes, and snippets.

@asim
Created April 20, 2011 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asim/930620 to your computer and use it in GitHub Desktop.
Save asim/930620 to your computer and use it in GitHub Desktop.
written by the boss
typedef struct {
int pos;
int size;
char *data;
} stack;
#define INITIAL_SIZE 1024
stack *init_stack() {
pos = 0;
size = INITIAL_SIZE;
data = calloc(sizeof(char) * INITIAL_SIZE);
}
void push(stack *stack, char *what) {
if(stack->pos == stack->size) {
stack->size *= 2;
stack->data = realloc(stack->data, stack->size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment