aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vppinfra/CMakeLists.txt7
-rw-r--r--src/vppinfra/config.h.in2
-rw-r--r--src/vppinfra/vec.c4
3 files changed, 13 insertions, 0 deletions
diff --git a/src/vppinfra/CMakeLists.txt b/src/vppinfra/CMakeLists.txt
index 3998ae6f6a6..7723e6bad5d 100644
--- a/src/vppinfra/CMakeLists.txt
+++ b/src/vppinfra/CMakeLists.txt
@@ -18,6 +18,13 @@ enable_language(ASM)
##############################################################################
set(LOG2_CACHE_LINE_BYTES ${VPP_LOG2_CACHE_LINE_SIZE})
+option(VPP_VECTOR_GROW_BY_ONE "Vectors grow by one, instead of 3/2" OFF)
+if(VPP_VECTOR_GROW_BY_ONE)
+ set(VECTOR_GROW_BY_ONE 1)
+else(VPP_VECTOR_GROW_BY_ONE)
+ set(VECTOR_GROW_BY_ONE 0)
+endif(VPP_VECTOR_GROW_BY_ONE)
+
configure_file(
${CMAKE_SOURCE_DIR}/vppinfra/config.h.in
${CMAKE_BINARY_DIR}/vppinfra/config.h
diff --git a/src/vppinfra/config.h.in b/src/vppinfra/config.h.in
index 1a8e03184a9..7aad027a8b6 100644
--- a/src/vppinfra/config.h.in
+++ b/src/vppinfra/config.h.in
@@ -21,4 +21,6 @@
#endif
#define CLIB_TARGET_TRIPLET "@CMAKE_C_COMPILER_TARGET@"
+#define CLIB_VECTOR_GROW_BY_ONE @VECTOR_GROW_BY_ONE@
+
#endif
diff --git a/src/vppinfra/vec.c b/src/vppinfra/vec.c
index 2ee78952d19..05a557ebb54 100644
--- a/src/vppinfra/vec.c
+++ b/src/vppinfra/vec.c
@@ -95,9 +95,13 @@ vec_resize_allocate_memory (void *v,
return v;
}
+#if CLIB_VECTOR_GROW_BY_ONE > 0
+ new_alloc_bytes = data_bytes;
+#else
new_alloc_bytes = (old_alloc_bytes * 3) / 2;
if (new_alloc_bytes < data_bytes)
new_alloc_bytes = data_bytes;
+#endif
new =
clib_mem_alloc_aligned_at_offset (new_alloc_bytes, data_align,