blob: 74fee4c0901194d7aeb3bd0cdbaa887e5faf9457 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// synacor challenge ([email protected])
#include "stack.h"
void stack_init(Stack *s) {
s->data = malloc(UINT16_MAX);
s->pointer = 0;
}
void stack_free(Stack *s) { free(s->data); }
void stack_push(Stack *s, u16 value) {
s->data[s->pointer] = value;
s->pointer = s->pointer + 1;
}
u16 stack_pop(Stack *s) {
u16 value = s->data[s->pointer - 1];
s->pointer = s->pointer - 1;
return value;
}
|