mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
(menu_entries.c) Less pointer grabbing
This commit is contained in:
parent
302d1ef99a
commit
c2e0e8d9fb
19
content.c
19
content.c
@ -50,6 +50,13 @@
|
||||
#include "cheevos.h"
|
||||
#endif
|
||||
|
||||
struct sram_block
|
||||
{
|
||||
unsigned type;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
static struct string_list *temporary_content;
|
||||
|
||||
/**
|
||||
@ -107,8 +114,8 @@ static void dump_to_file_desperate(const void *data,
|
||||
size_t size, unsigned type)
|
||||
{
|
||||
time_t time_;
|
||||
char timebuf[256];
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
char timebuf[PATH_MAX_LENGTH] = {0};
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
const char *base = getenv("APPDATA");
|
||||
#elif defined(__CELLOS_LV2__) || defined(_XBOX)
|
||||
@ -138,12 +145,6 @@ error:
|
||||
RARCH_WARN("Failed ... Cannot recover save file.\n");
|
||||
}
|
||||
|
||||
struct sram_block
|
||||
{
|
||||
unsigned type;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* save_state:
|
||||
@ -336,9 +337,7 @@ void save_ram_file(const char *path, int type)
|
||||
size_t size = core.retro_get_memory_size(type);
|
||||
void *data = core.retro_get_memory_data(type);
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
if (size == 0)
|
||||
if (!data || size == 0)
|
||||
return;
|
||||
|
||||
if (!retro_write_file(path, data, size))
|
||||
|
@ -47,7 +47,8 @@
|
||||
#include "deps/7zip/7zCrc.h"
|
||||
#include "deps/7zip/7zFile.h"
|
||||
|
||||
static bool Utf16_To_Char(uint8_t **utf_data, size_t *dest_len, const uint16_t *in)
|
||||
static bool Utf16_To_Char(uint8_t **utf_data,
|
||||
size_t *dest_len, const uint16_t *in)
|
||||
{
|
||||
unsigned len = 0;
|
||||
|
||||
@ -63,11 +64,13 @@ static bool Utf16_To_Char(uint8_t **utf_data, size_t *dest_len, const uint16_t *
|
||||
return utf16_conv_utf8(*utf_data, dest_len, in, len);
|
||||
}
|
||||
|
||||
static bool ConvertUtf16toCharString(const uint16_t *in, char *s, size_t len)
|
||||
static bool ConvertUtf16toCharString(const uint16_t *in,
|
||||
char *s, size_t len)
|
||||
{
|
||||
size_t dest_len = 0;
|
||||
uint8_t *utf16_data = NULL;
|
||||
bool ret = Utf16_To_Char(&utf16_data, &dest_len, in);
|
||||
bool ret = Utf16_To_Char(
|
||||
&utf16_data, &dest_len, in);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
|
@ -234,9 +234,6 @@ typedef struct
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
} menu_state;
|
||||
|
||||
/* Menu entries */
|
||||
menu_entries_t *entries;
|
||||
|
||||
bool load_no_content;
|
||||
|
||||
/* Menu shader */
|
||||
|
@ -43,6 +43,8 @@ struct menu_entries
|
||||
rarch_setting_t *list_settings;
|
||||
};
|
||||
|
||||
static menu_entries_t *menu_entries_data;
|
||||
|
||||
static void menu_list_free_list(file_list_t *list)
|
||||
{
|
||||
unsigned i;
|
||||
@ -352,18 +354,9 @@ void menu_entries_refresh(file_list_t *list)
|
||||
}
|
||||
}
|
||||
|
||||
static menu_entries_t *menu_entries_get_ptr(void)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
if (!menu)
|
||||
return NULL;
|
||||
|
||||
return menu->entries;
|
||||
}
|
||||
|
||||
rarch_setting_t *menu_setting_get_ptr(void)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
|
||||
if (!entries)
|
||||
return NULL;
|
||||
@ -372,7 +365,7 @@ rarch_setting_t *menu_setting_get_ptr(void)
|
||||
|
||||
menu_list_t *menu_list_get_ptr(void)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
if (!entries)
|
||||
return NULL;
|
||||
return entries->menu_list;
|
||||
@ -381,7 +374,7 @@ menu_list_t *menu_list_get_ptr(void)
|
||||
/* Sets the starting index of the menu entry list. */
|
||||
void menu_entries_set_start(size_t i)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
|
||||
if (entries)
|
||||
entries->begin = i;
|
||||
@ -390,7 +383,7 @@ void menu_entries_set_start(size_t i)
|
||||
/* Returns the starting index of the menu entry list. */
|
||||
size_t menu_entries_get_start(void)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
|
||||
if (!entries)
|
||||
return 0;
|
||||
@ -506,7 +499,7 @@ file_list_t *menu_entries_get_selection_buf_ptr(size_t idx)
|
||||
|
||||
bool menu_entries_needs_refresh(void)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
|
||||
if (!entries || entries->nonblocking_refresh)
|
||||
return false;
|
||||
@ -517,7 +510,7 @@ bool menu_entries_needs_refresh(void)
|
||||
|
||||
void menu_entries_set_refresh(bool nonblocking)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
if (entries)
|
||||
{
|
||||
if (nonblocking)
|
||||
@ -529,7 +522,7 @@ void menu_entries_set_refresh(bool nonblocking)
|
||||
|
||||
void menu_entries_unset_refresh(bool nonblocking)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
if (entries)
|
||||
{
|
||||
if (nonblocking)
|
||||
@ -541,21 +534,17 @@ void menu_entries_unset_refresh(bool nonblocking)
|
||||
|
||||
bool menu_entries_init(void *data)
|
||||
{
|
||||
menu_entries_t *entries = NULL;
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
if (!menu)
|
||||
goto error;
|
||||
|
||||
entries = (menu_entries_t*)calloc(1, sizeof(*entries));
|
||||
menu_entries_t *entries = (menu_entries_t*)
|
||||
calloc(1, sizeof(*entries));
|
||||
|
||||
if (!entries)
|
||||
goto error;
|
||||
|
||||
menu->entries = (struct menu_entries*)entries;
|
||||
|
||||
if (!(entries->menu_list = (menu_list_t*)menu_list_new()))
|
||||
goto error;
|
||||
|
||||
menu_entries_data = (struct menu_entries*)entries;
|
||||
|
||||
entries->list_settings = menu_setting_new();
|
||||
|
||||
return true;
|
||||
@ -563,14 +552,12 @@ bool menu_entries_init(void *data)
|
||||
error:
|
||||
if (entries)
|
||||
free(entries);
|
||||
if (menu)
|
||||
menu->entries = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
void menu_entries_free(void)
|
||||
{
|
||||
menu_entries_t *entries = menu_entries_get_ptr();
|
||||
menu_entries_t *entries = menu_entries_data;
|
||||
|
||||
if (!entries)
|
||||
return;
|
||||
@ -581,6 +568,9 @@ void menu_entries_free(void)
|
||||
|
||||
menu_list_free(entries->menu_list);
|
||||
entries->menu_list = NULL;
|
||||
|
||||
free(menu_entries_data);
|
||||
menu_entries_data = NULL;
|
||||
}
|
||||
|
||||
void menu_entries_push(file_list_t *list, const char *path, const char *label,
|
||||
|
Loading…
x
Reference in New Issue
Block a user