free(s->data);
}
-#define push(s,x) { \
- if (s->top>=s->max_size) { \
- s->max_size *= 2; \
- s->data = realloc(s->data, s->max_size*sizeof(Pair)); \
- } \
- s->data[s->top++] = x; \
+static void push(PairStack *s, Pair x) {
+ if (s->top >= s->max_size) {
+ s->max_size *= 2;
+ s->data = realloc(s->data, s->max_size * sizeof(Pair));
+ }
+ s->data[s->top++] = x;
}
-#define pop(s,x) ((s->top==0) ? FALSE : (s->top--, x = s->data[s->top], TRUE))
+static bool pop(PairStack *s, Pair *x) {
+ if (s->top == 0)
+ return false;
+ --s->top;
+ *x = s->data[s->top];
+ return true;
+}
#define sub(h,i) (h->data[i])
free(degrees);
/* add all edges from stack */
- while (pop(edges_stack, pair)) {
+ while (pop(edges_stack, &pair)) {
add_edge(new_graph, pair.left, pair.right);
}
}