aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api-test
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2015-12-15 13:22:37 +0000
committerGerrit Code Review <gerrit@projectrotterdam.info>2015-12-15 13:22:37 +0000
commit317be0349275f1f461028853d936670729591796 (patch)
tree2423d844a2f9ed9176f54ce5d07a368e248e9e6f /vpp-api-test
parentec65a1afd3f118849a7629d99ab2a1dcd2dda341 (diff)
parentd2dc3df90d20419dfaee03f3096ed18d20fa391a (diff)
Merge "replacing all vec_sort() invocations to vec_sort_with_function()"
Diffstat (limited to 'vpp-api-test')
-rw-r--r--vpp-api-test/vat/api_format.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 02c3ad5fe06..352a78a6a4a 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -2019,6 +2019,14 @@ static int dump_sub_interface_table (vat_main_t * vam)
return 0;
}
+static int name_sort_cmp (void * a1, void * a2)
+{
+ name_sort_t * n1 = a1;
+ name_sort_t * n2 = a2;
+
+ return strcmp ((char *)n1->name, (char *)n2->name);
+}
+
static int dump_interface_table (vat_main_t * vam)
{
hash_pair_t * p;
@@ -2036,8 +2044,7 @@ static int dump_interface_table (vat_main_t * vam)
ns->value = (u32) p->value[0];
}));
- vec_sort (nses, n1, n2,
- strcmp ((char *)n1->name, (char *)n2->name));
+ vec_sort_with_function (nses, name_sort_cmp);
fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
vec_foreach (ns, nses) {
@@ -8275,6 +8282,14 @@ static int comment (vat_main_t * vam)
return 0;
}
+static int cmd_cmp (void * a1, void * a2)
+{
+ u8 ** c1 = a1;
+ u8 ** c2 = a2;
+
+ return strcmp ((char *)(c1[0]), (char *)(c2[0]));
+}
+
static int help (vat_main_t * vam)
{
u8 ** cmds = 0;
@@ -8304,8 +8319,7 @@ static int help (vat_main_t * vam)
vec_add1 (cmds, (u8 *)(p->key));
}));
- vec_sort (cmds, c1, c2,
- strcmp ((char *)(c1[0]), (char *)(c2[0])));
+ vec_sort_with_function (cmds, cmd_cmp);
for (j = 0; j < vec_len(cmds); j++)
fformat (vam->ofp, "%s\n", cmds[j]);
@@ -8356,6 +8370,14 @@ typedef struct {
} macro_sort_t;
+static int macro_sort_cmp (void * a1, void * a2)
+{
+ macro_sort_t * s1 = a1;
+ macro_sort_t * s2 = a2;
+
+ return strcmp ((char *)(s1->name), (char *)(s2->name));
+}
+
static int dump_macro_table (vat_main_t * vam)
{
macro_sort_t * sort_me = 0, * sm;
@@ -8369,7 +8391,7 @@ static int dump_macro_table (vat_main_t * vam)
sm->value = (u8 *) (p->value[0]);
}));
- vec_sort (sort_me, s1, s2, strcmp ((char *)(s1->name), (char *)(s2->name)));
+ vec_sort_with_function (sort_me, macro_sort_cmp);
if (vec_len(sort_me))
fformat (vam->ofp, "%-15s%s\n", "Name", "Value");