Merge pull request #3264 from ianyfan/resize-list

list: double list capacity when resizing instead of incrementing
This commit is contained in:
Brian Ashworth 2018-12-08 22:40:13 -05:00 committed by GitHub
commit e7efa0e27b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,7 @@ list_t *create_list(void) {
static void list_resize(list_t *list) { static void list_resize(list_t *list) {
if (list->length == list->capacity) { if (list->length == list->capacity) {
list->capacity += 10; list->capacity *= 2;
list->items = realloc(list->items, sizeof(void*) * list->capacity); list->items = realloc(list->items, sizeof(void*) * list->capacity);
} }
} }