vlib: introduce vlib_get_main_by_index(), vlib_get_n_threads()

Type: improvement
Change-Id: If3da7d4338470912f37ff1794620418d928fb77f
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 96e22a2..6c98867 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -2886,9 +2886,9 @@
        * the same new name.
        * Then, throw away the old shared name-vector.
        */
-      for (i = 0; i < vec_len (vlib_mains); i++)
+      for (i = 0; i < vlib_get_n_threads (); i++)
 	{
-	  this_vlib_main = vlib_mains[i];
+	  this_vlib_main = vlib_get_main_by_index (i);
 	  if (this_vlib_main == 0)
 	    continue;
 	  n = vlib_get_node (this_vlib_main,