]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
country-list: Grow like AS list
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Mar 2022 10:19:10 +0000 (10:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Mar 2022 10:19:10 +0000 (10:19 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/country-list.c

index 6c4953395c121eab65a5eb4fe45d816b8db0bb57..4d5ef08126bf256da11aa6f2ea117c1644fecfa4 100644 (file)
@@ -31,7 +31,11 @@ struct loc_country_list {
        size_t size;
 };
 
-static int loc_country_list_grow(struct loc_country_list* list, size_t size) {
+static int loc_country_list_grow(struct loc_country_list* list) {
+       size_t size = list->elements_size * 2;
+       if (size < 1024)
+               size = 1024;
+
        DEBUG(list->ctx, "Growing country list %p by %zu to %zu\n",
                list, size, list->elements_size + size);
 
@@ -124,7 +128,7 @@ LOC_EXPORT int loc_country_list_append(
 
        // Check if we have space left
        if (list->size >= list->elements_size) {
-               int r = loc_country_list_grow(list, 64);
+               int r = loc_country_list_grow(list);
                if (r)
                        return r;
        }