aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api-test
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2015-12-14 10:31:33 -0500
committerDamjan Marion <damarion@cisco.com>2015-12-15 00:09:46 +0100
commitd2dc3df90d20419dfaee03f3096ed18d20fa391a (patch)
tree3315705df01fdb840ddb828fff779748154930b8 /vpp-api-test
parentf9bd620dc5299180cb639c4c6f91fadf6b860b08 (diff)
replacing all vec_sort() invocations to vec_sort_with_function()
Change-Id: I05895827ed52be292112484cee7d0a2591b67335 Signed-off-by: Matus Fabian <matfabia@cisco.com>
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 02c3ad5f..352a78a6 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");