X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fvec.h;h=a029630559c4763650079753fa170227802eb737;hb=eb987d3a09f669787014b1553f032219522149e1;hp=d70e9ce127621ef49215471e81f342921acb0e9f;hpb=614ac5da53bca8c8fad5733e6749ec8753c52f28;p=vpp.git diff --git a/src/vppinfra/vec.h b/src/vppinfra/vec.h index d70e9ce1276..a029630559c 100644 --- a/src/vppinfra/vec.h +++ b/src/vppinfra/vec.h @@ -145,14 +145,14 @@ _vec_resize (void *v, data_align)); } -/** \brief Low-level vector resize predicate +/** \brief Determine if vector will resize with next allocation @param v pointer to a vector @param length_increment length increment in elements @param data_bytes requested size in bytes @param header_bytes header size in bytes (may be zero) @param data_align alignment (may be zero) - @return v_prime pointer to resized vector, may or may not equal v + @return 1 if vector will resize 0 otherwise */ always_inline int @@ -161,7 +161,6 @@ _vec_resize_will_expand (void *v, uword data_bytes, uword header_bytes, uword data_align) { - vec_header_t *vh = _vec_find (v); uword new_data_bytes, aligned_header_bytes; aligned_header_bytes = vec_header_bytes (header_bytes); @@ -177,10 +176,7 @@ _vec_resize_will_expand (void *v, /* Typically we'll not need to resize. */ if (new_data_bytes <= clib_mem_size (p)) - { - vh->len += length_increment; - return 0; - } + return 0; } return 1; } @@ -415,6 +411,8 @@ do { \ #define vec_validate_ha(V,I,H,A) \ do { \ + STATIC_ASSERT(A==0 || ((A % sizeof(V[0]))==0) || ((sizeof(V[0]) % A) == 0),\ + "vector validate aligned on incorrectly sized object"); \ word _v(i) = (I); \ word _v(l) = vec_len (V); \ if (_v(i) >= _v(l)) \ @@ -495,7 +493,7 @@ do { \ @param A alignment (may be zero) @return V (value-result macro parameter) */ -#define vec_validate_init_empty_aligned(V,I,A) \ +#define vec_validate_init_empty_aligned(V,I,INIT,A) \ vec_validate_init_empty_ha(V,I,INIT,0,A) /** \brief Add 1 element to end of vector (general version). @@ -943,7 +941,7 @@ do { \ word _v(i) = 0; \ while (_v(i) < vec_len(v)) \ { \ - if (v[_v(i)] == E) \ + if ((v)[_v(i)] == E) \ break; \ _v(i)++; \ } \