Don't use nested functions.
This allows tinc to be compiled with Clang.
This commit is contained in:
parent
eb80105ea8
commit
d5f0ff5df8
1 changed files with 57 additions and 57 deletions
48
src/top.c
48
src/top.c
|
@ -136,28 +136,7 @@ static void update(int fd) {
|
|||
}
|
||||
}
|
||||
|
||||
static void redraw(void) {
|
||||
erase();
|
||||
|
||||
mvprintw(0, 0, "Tinc %-16s Nodes: %4d Sort: %-10s %s", netname ?: "", node_list.count, sortname[sortmode], cumulative ? "Cumulative" : "Current");
|
||||
attrset(A_REVERSE);
|
||||
mvprintw(2, 0, "Node IN pkts IN %s OUT pkts OUT %s", unit, unit);
|
||||
chgat(-1, A_REVERSE, 0, NULL);
|
||||
|
||||
static nodestats_t **sorted = 0;
|
||||
static int n = 0;
|
||||
if(changed) {
|
||||
n = 0;
|
||||
sorted = xrealloc(sorted, node_list.count * sizeof *sorted);
|
||||
for list_each(nodestats_t, ns, &node_list)
|
||||
sorted[n++] = ns;
|
||||
changed = false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < n; i++)
|
||||
sorted[i]->i = i;
|
||||
|
||||
int cmpfloat(float a, float b) {
|
||||
static int cmpfloat(float a, float b) {
|
||||
if(a < b)
|
||||
return -1;
|
||||
else if(a > b)
|
||||
|
@ -166,7 +145,7 @@ static void redraw(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cmpu64(uint64_t a, uint64_t b) {
|
||||
static int cmpu64(uint64_t a, uint64_t b) {
|
||||
if(a < b)
|
||||
return -1;
|
||||
else if(a > b)
|
||||
|
@ -175,7 +154,7 @@ static void redraw(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sortfunc(const void *a, const void *b) {
|
||||
static int sortfunc(const void *a, const void *b) {
|
||||
const nodestats_t *na = *(const nodestats_t **)a;
|
||||
const nodestats_t *nb = *(const nodestats_t **)b;
|
||||
switch(sortmode) {
|
||||
|
@ -214,6 +193,27 @@ static void redraw(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void redraw(void) {
|
||||
erase();
|
||||
|
||||
mvprintw(0, 0, "Tinc %-16s Nodes: %4d Sort: %-10s %s", netname ?: "", node_list.count, sortname[sortmode], cumulative ? "Cumulative" : "Current");
|
||||
attrset(A_REVERSE);
|
||||
mvprintw(2, 0, "Node IN pkts IN %s OUT pkts OUT %s", unit, unit);
|
||||
chgat(-1, A_REVERSE, 0, NULL);
|
||||
|
||||
static nodestats_t **sorted = 0;
|
||||
static int n = 0;
|
||||
if(changed) {
|
||||
n = 0;
|
||||
sorted = xrealloc(sorted, node_list.count * sizeof *sorted);
|
||||
for list_each(nodestats_t, ns, &node_list)
|
||||
sorted[n++] = ns;
|
||||
changed = false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < n; i++)
|
||||
sorted[i]->i = i;
|
||||
|
||||
qsort(sorted, n, sizeof *sorted, sortfunc);
|
||||
|
||||
for(int i = 0, row = 3; i < n; i++, row++) {
|
||||
|
|
Loading…
Reference in a new issue