mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-10 21:10:15 +00:00
Rename ptr member to more sensible name 'size' and kill rgui_list_size
This commit is contained in:
parent
e06b125ab2
commit
b348e3f390
@ -389,8 +389,8 @@ static void render_text(rgui_handle_t *rgui)
|
||||
|
||||
size_t begin = rgui->directory_ptr >= TERM_HEIGHT / 2 ?
|
||||
rgui->directory_ptr - TERM_HEIGHT / 2 : 0;
|
||||
size_t end = rgui->directory_ptr + TERM_HEIGHT <= rgui_list_size(rgui->folder_buf) ?
|
||||
rgui->directory_ptr + TERM_HEIGHT : rgui_list_size(rgui->folder_buf);
|
||||
size_t end = rgui->directory_ptr + TERM_HEIGHT <= rgui->folder_buf->size ?
|
||||
rgui->directory_ptr + TERM_HEIGHT : rgui->folder_buf->size;
|
||||
|
||||
if (end - begin > TERM_HEIGHT)
|
||||
end = begin + TERM_HEIGHT;
|
||||
@ -1187,11 +1187,11 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
if (rgui->directory_ptr > 0)
|
||||
rgui->directory_ptr--;
|
||||
else
|
||||
rgui->directory_ptr = rgui_list_size(rgui->folder_buf) - 1;
|
||||
rgui->directory_ptr = rgui->folder_buf->size - 1;
|
||||
break;
|
||||
|
||||
case RGUI_ACTION_DOWN:
|
||||
if (rgui->directory_ptr + 1 < rgui_list_size(rgui->folder_buf))
|
||||
if (rgui->directory_ptr + 1 < rgui->folder_buf->size)
|
||||
rgui->directory_ptr++;
|
||||
else
|
||||
rgui->directory_ptr = 0;
|
||||
@ -1199,7 +1199,7 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
|
||||
case RGUI_ACTION_CANCEL:
|
||||
case RGUI_ACTION_SETTINGS:
|
||||
if (rgui_list_size(rgui->path_stack) > 1)
|
||||
if (rgui->path_stack->size > 1)
|
||||
{
|
||||
rgui_list_pop(rgui->path_stack);
|
||||
rgui->directory_ptr = directory_ptr;
|
||||
@ -1298,11 +1298,11 @@ int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
if (rgui->directory_ptr > 0)
|
||||
rgui->directory_ptr--;
|
||||
else
|
||||
rgui->directory_ptr = rgui_list_size(rgui->folder_buf) - 1;
|
||||
rgui->directory_ptr = rgui->folder_buf->size - 1;
|
||||
break;
|
||||
|
||||
case RGUI_ACTION_DOWN:
|
||||
if (rgui->directory_ptr + 1 < rgui_list_size(rgui->folder_buf))
|
||||
if (rgui->directory_ptr + 1 < rgui->folder_buf->size)
|
||||
rgui->directory_ptr++;
|
||||
else
|
||||
rgui->directory_ptr = 0;
|
||||
@ -1316,14 +1316,14 @@ int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
break;
|
||||
|
||||
case RGUI_ACTION_RIGHT:
|
||||
if (rgui->directory_ptr + 8 < rgui_list_size(rgui->folder_buf))
|
||||
if (rgui->directory_ptr + 8 < rgui->folder_buf->size)
|
||||
rgui->directory_ptr += 8;
|
||||
else
|
||||
rgui->directory_ptr = rgui_list_size(rgui->folder_buf) - 1;
|
||||
rgui->directory_ptr = rgui->folder_buf->size - 1;
|
||||
break;
|
||||
|
||||
case RGUI_ACTION_CANCEL:
|
||||
if (rgui_list_size(rgui->path_stack) > 1)
|
||||
if (rgui->path_stack->size > 1)
|
||||
{
|
||||
rgui->need_refresh = true;
|
||||
rgui->directory_ptr = directory_ptr;
|
||||
@ -1333,7 +1333,7 @@ int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
|
||||
case RGUI_ACTION_OK:
|
||||
{
|
||||
if (rgui_list_size(rgui->folder_buf) == 0)
|
||||
if (rgui->folder_buf->size == 0)
|
||||
return 0;
|
||||
|
||||
const char *path = 0;
|
||||
|
@ -32,7 +32,7 @@ struct rgui_list
|
||||
struct rgui_file *list;
|
||||
|
||||
size_t capacity;
|
||||
size_t ptr;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
rgui_list_t *rgui_list_new(void)
|
||||
@ -42,34 +42,34 @@ rgui_list_t *rgui_list_new(void)
|
||||
|
||||
bool rgui_list_empty(const rgui_list_t *list)
|
||||
{
|
||||
return list->ptr == 0;
|
||||
return list->size == 0;
|
||||
}
|
||||
|
||||
void rgui_list_push(rgui_list_t *list,
|
||||
const char *path, unsigned type, size_t directory_ptr)
|
||||
{
|
||||
if (list->ptr >= list->capacity)
|
||||
if (list->size >= list->capacity)
|
||||
{
|
||||
list->capacity++;
|
||||
list->capacity *= 2;
|
||||
list->list = (struct rgui_file*)realloc(list->list, list->capacity * sizeof(struct rgui_file));
|
||||
}
|
||||
|
||||
list->list[list->ptr].path = strdup(path);
|
||||
list->list[list->ptr].type = type;
|
||||
list->list[list->ptr].directory_ptr = directory_ptr;
|
||||
list->ptr++;
|
||||
list->list[list->size].path = strdup(path);
|
||||
list->list[list->size].type = type;
|
||||
list->list[list->size].directory_ptr = directory_ptr;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
void rgui_list_pop(rgui_list_t *list)
|
||||
{
|
||||
if (!rgui_list_empty(list))
|
||||
free(list->list[--list->ptr].path);
|
||||
free(list->list[--list->size].path);
|
||||
}
|
||||
|
||||
void rgui_list_free(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->ptr; i++)
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
free(list->list[i].path);
|
||||
free(list->list);
|
||||
free(list);
|
||||
@ -77,9 +77,9 @@ void rgui_list_free(rgui_list_t *list)
|
||||
|
||||
void rgui_list_clear(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->ptr; i++)
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
free(list->list[i].path);
|
||||
list->ptr = 0;
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
@ -96,13 +96,8 @@ void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
void rgui_list_get_last(const rgui_list_t *list,
|
||||
const char **path, unsigned *file_type, size_t *directory_ptr)
|
||||
{
|
||||
if (rgui_list_size(list) > 0)
|
||||
rgui_list_get_at_offset(list, rgui_list_size(list) - 1, path, file_type, directory_ptr);
|
||||
}
|
||||
|
||||
size_t rgui_list_size(const rgui_list_t *list)
|
||||
{
|
||||
return list->ptr;
|
||||
if (list->size > 0)
|
||||
rgui_list_get_at_offset(list, list->size - 1, path, file_type, directory_ptr);
|
||||
}
|
||||
|
||||
static int list_comp(const void *a_, const void *b_)
|
||||
@ -118,5 +113,5 @@ static int list_comp(const void *a_, const void *b_)
|
||||
|
||||
void rgui_list_sort(rgui_list_t *list)
|
||||
{
|
||||
qsort(list->list, list->ptr, sizeof(struct rgui_file), list_comp);
|
||||
qsort(list->list, list->size, sizeof(struct rgui_file), list_comp);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ bool rgui_list_empty(const rgui_list_t *list);
|
||||
void rgui_list_get_last(const rgui_list_t *list,
|
||||
const char **path, unsigned *type, size_t *directory_ptr);
|
||||
|
||||
size_t rgui_list_size(const rgui_list_t *list);
|
||||
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **path, unsigned *type, size_t *directory_ptr);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user