From: Miroslav Lichvar Date: Wed, 24 Sep 2014 11:22:31 +0000 (+0200) Subject: sources: reallocate arrays in exponentially increasing sizes X-Git-Tag: 2.0-pre1~99 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5a85bd2fed2e9a55a7c7900a10ff9dc40c4b2ee;p=thirdparty%2Fchrony.git sources: reallocate arrays in exponentially increasing sizes --- diff --git a/sources.c b/sources.c index 1ab0a991..30d6144d 100644 --- a/sources.c +++ b/sources.c @@ -207,7 +207,7 @@ SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOpt if (n_sources == max_n_sources) { /* Reallocate memory */ - max_n_sources += 32; + max_n_sources = max_n_sources > 0 ? 2 * max_n_sources : 4; if (sources) { sources = ReallocArray(struct SRC_Instance_Record *, max_n_sources, sources); sort_list = ReallocArray(struct Sort_Element, 3*max_n_sources, sort_list);