diff options
author | Stef Walter <stef@thewalter.net> | 2014-08-07 08:38:46 +0200 |
---|---|---|
committer | Stef Walter <stefw@redhat.com> | 2014-10-13 17:54:03 +0200 |
commit | bb7284bb7e708792198d39cfa248467394ee5896 (patch) | |
tree | 4d3ed97ebbd12ca732782704769ee19fe9d67ff7 | |
parent | 0ecc141f372b375ddd2087a8ca406797976f03bf (diff) | |
download | p11-kit-stable.tar.gz |
common: Don't do repeated linear reallocation of array memorystable
Some mallocs (notably on Windows) have really poor behavior when
called repeatedly with a linearly growing buffer.
https://bugzilla.redhat.com/show_bug.cgi?id=985419
-rw-r--r-- | common/array.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/common/array.c b/common/array.c index 9802100..9bff748 100644 --- a/common/array.c +++ b/common/array.c @@ -48,7 +48,10 @@ maybe_expand_array (p11_array *array, if (length <= array->allocated) return true; - new_allocated = array->allocated + 16; + + new_allocated = array->allocated * 2; + if (new_allocated == 0) + new_allocated = 16; if (new_allocated < length) new_allocated = length; |