mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Fix kvz_image_list_add for zero-sized lists.
When a list does not have space for the new element, its size is doubled. If the size of the list is zero, it would not be resized. Fixed to always resize the list so that the new element can be added.
This commit is contained in:
parent
433e528af7
commit
62ad57d0bf
|
@ -35,13 +35,10 @@
|
||||||
image_list_t * kvz_image_list_alloc(int size)
|
image_list_t * kvz_image_list_alloc(int size)
|
||||||
{
|
{
|
||||||
image_list_t *list = (image_list_t *)malloc(sizeof(image_list_t));
|
image_list_t *list = (image_list_t *)malloc(sizeof(image_list_t));
|
||||||
list->size = size;
|
list->size = size;
|
||||||
if (size > 0) {
|
list->images = malloc(sizeof(kvz_picture*) * size);
|
||||||
list->images = (kvz_picture**)malloc(sizeof(kvz_picture*) * size);
|
list->cu_arrays = malloc(sizeof(cu_array_t*) * size);
|
||||||
list->cu_arrays = (cu_array_t**)malloc(sizeof(cu_array_t*) * size);
|
list->pocs = malloc(sizeof(int32_t) * size);
|
||||||
list->pocs = malloc(sizeof(int32_t) * size);
|
|
||||||
}
|
|
||||||
|
|
||||||
list->used_size = 0;
|
list->used_size = 0;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -114,7 +111,8 @@ int kvz_image_list_add(image_list_t *list, kvz_picture *im, cu_array_t *cua, int
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list->size == list->used_size) {
|
if (list->size == list->used_size) {
|
||||||
if (!kvz_image_list_resize(list, list->size*2)) return 0;
|
unsigned new_size = MAX(list->size + 1, list->size * 2);
|
||||||
|
if (!kvz_image_list_resize(list, new_size)) return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = list->used_size; i > 0; i--) {
|
for (i = list->used_size; i > 0; i--) {
|
||||||
|
|
Loading…
Reference in a new issue