From: "Edgar E. Iglesias" <[email protected]> Use a simple over-allocation scheme that allocates 4 slots for future growth.
Signed-off-by: Edgar E. Iglesias <[email protected]> --- vect.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/vect.c b/vect.c index 7dae847..b01b70e 100644 --- a/vect.c +++ b/vect.c @@ -82,7 +82,8 @@ int vect_reserve(struct vect *vec, size_t count) { if (count > vec->allocated) { - size_t na = vec->allocated != 0 ? 2 * vec->allocated : 4; + /* Allocate 4 extra slots for growth. */ + size_t na = count + 4; void *n = realloc(vec->data, na * vec->elt_size); if (n == NULL) return -1; -- 1.7.8.6 _______________________________________________ Ltrace-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/ltrace-devel
