Preallocate mhash key_tmps vector

Fix os_get_nthreads() so that it starts returning the correct answer
as early as possible.

Change-Id: Id5292262f2c3f521b07ffbe6a9f6748dcc4dcb7d
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/vppinfra/mhash.c b/src/vppinfra/mhash.c
index d4d5457..791aa36 100644
--- a/src/vppinfra/mhash.c
+++ b/src/vppinfra/mhash.c
@@ -205,13 +205,7 @@
   clib_memset (h, 0, sizeof (h[0]));
   h->n_key_bytes = n_key_bytes;
 
-#if 0
-  if (h->n_key_bytes > 0)
-    {
-      vec_validate (h->key_tmp, h->n_key_bytes - 1);
-      _vec_len (h->key_tmp) = 0;
-    }
-#endif
+  vec_validate (h->key_tmps, os_get_nthreads () - 1);
 
   ASSERT (n_key_bytes < ARRAY_LEN (t));
   h->hash = hash_create2 ( /* elts */ 0,
@@ -228,7 +222,6 @@
   u8 *key_tmp;
   int my_cpu = os_get_thread_index ();
 
-  vec_validate (h->key_tmps, my_cpu);
   key_tmp = h->key_tmps[my_cpu];
 
   vec_reset_length (key_tmp);