blob: 9fde1e6d3ee1004a98bbad3b7e7f2bc52e5054dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "stack.h"
void stack_push(ll_t **q, v_t x) {
ll_t *nq = malloc(sizeof(ll_t));
nq->x = x;
nq->next = *q;
*q = nq;
}
void stack_push_d(dll_t **q, double x) {
dll_t *nq = malloc(sizeof(dll_t));
nq->x = x;
nq->next = *q;
*q = nq;
}
v_t stack_pop(ll_t **q) {
ll_t *old_q = *q;
*q = old_q->next;
v_t x = old_q->x;
free(old_q);
return x;
}
double stack_pop_d(dll_t **q) {
dll_t *old_q = *q;
*q = old_q->next;
double x = old_q->x;
free(old_q);
return x;
}
|