Return 0 if the supplied vector pointer is NULL.
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Icb0aab70e0b7c9c1ddcf607c9dfb7e5715f177d1
})
/** \brief Total number of elements that can fit into vector. */
-#define vec_max_len(v) (vec_capacity(v,0) / sizeof (v[0]))
+#define vec_max_len(v) \
+ ((v) ? (vec_capacity (v,0) - vec_header_bytes (0)) / sizeof (v[0]) : 0)
/** \brief Set vector length to a user-defined value */
#ifndef __COVERITY__ /* Coverity gets confused by ASSERT() */