mirror of
https://github.com/libretro/RetroArch
synced 2025-03-17 10:21:26 +00:00
More string_list removal
This commit is contained in:
parent
761d740e46
commit
d7d1011ab0
@ -6181,47 +6181,62 @@ static int action_ok_delete_entry(const char *path,
|
||||
static int action_ok_rdb_entry_submenu(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char *tok, *save;
|
||||
union string_list_elem_attr attr;
|
||||
char new_label[PATH_MAX_LENGTH];
|
||||
char *elem0 = NULL;
|
||||
char *elem1 = NULL;
|
||||
char *elem2 = NULL;
|
||||
int ret = -1;
|
||||
char *rdb = NULL;
|
||||
int len = 0;
|
||||
struct string_list str_list = {0};
|
||||
struct string_list str_list2 = {0};
|
||||
char *label_cpy = NULL;
|
||||
|
||||
if (!label)
|
||||
return -1;
|
||||
|
||||
label_cpy = strdup(label);
|
||||
|
||||
new_label[0] = '\0';
|
||||
|
||||
string_list_initialize(&str_list);
|
||||
if (!string_split_noalloc(&str_list, label, "|"))
|
||||
goto end;
|
||||
|
||||
string_list_initialize(&str_list2);
|
||||
|
||||
/* element 0 : label
|
||||
* element 1 : value
|
||||
* element 2 : database path
|
||||
*/
|
||||
if ((tok = strtok_r(label_cpy, "|", &save)))
|
||||
elem0 = strdup(tok);
|
||||
if ((tok = strtok_r(NULL, "|", &save)))
|
||||
elem1 = strdup(tok);
|
||||
if ((tok = strtok_r(NULL, "|", &save)))
|
||||
elem2 = strdup(tok);
|
||||
free(label_cpy);
|
||||
|
||||
string_list_initialize(&str_list2);
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
len += strlen(str_list.elems[1].data) + 1;
|
||||
string_list_append(&str_list2, str_list.elems[1].data, attr);
|
||||
len += strlen(elem1) + 1;
|
||||
string_list_append(&str_list2, elem1, attr);
|
||||
free(elem1);
|
||||
|
||||
len += strlen(str_list.elems[2].data) + 1;
|
||||
string_list_append(&str_list2, str_list.elems[2].data, attr);
|
||||
len += strlen(elem2) + 1;
|
||||
string_list_append(&str_list2, elem2, attr);
|
||||
free(elem2);
|
||||
|
||||
if (!(rdb = (char*)calloc(len, sizeof(char))))
|
||||
{
|
||||
if (elem0)
|
||||
free(elem0);
|
||||
goto end;
|
||||
}
|
||||
|
||||
string_list_join_concat(rdb, len, &str_list2, "|");
|
||||
|
||||
fill_pathname_join_delim(new_label,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST),
|
||||
str_list.elems[0].data, '_',
|
||||
sizeof(new_label));
|
||||
elem0, '_', sizeof(new_label));
|
||||
free(elem0);
|
||||
|
||||
ret = generic_action_ok_displaylist_push(
|
||||
rdb, NULL,
|
||||
@ -6232,7 +6247,6 @@ static int action_ok_rdb_entry_submenu(const char *path,
|
||||
end:
|
||||
if (rdb)
|
||||
free(rdb);
|
||||
string_list_deinitialize(&str_list);
|
||||
string_list_deinitialize(&str_list2);
|
||||
|
||||
return ret;
|
||||
|
53
retroarch.c
53
retroarch.c
@ -2168,8 +2168,9 @@ struct string_list *dir_list_new_special(const char *input_dir,
|
||||
char ext_shaders[255];
|
||||
#endif
|
||||
char ext_name[16];
|
||||
const char *exts = NULL;
|
||||
bool recursive = false;
|
||||
size_t _len = 0;
|
||||
const char *exts = NULL;
|
||||
bool recursive = false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@ -2196,36 +2197,36 @@ struct string_list *dir_list_new_special(const char *input_dir,
|
||||
case DIR_LIST_SHADERS:
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
struct string_list str_list;
|
||||
|
||||
if (!string_list_initialize(&str_list))
|
||||
return NULL;
|
||||
|
||||
ext_shaders[0] = '\0';
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
if (video_shader_is_supported(RARCH_SHADER_CG))
|
||||
{
|
||||
string_list_append(&str_list, "cgp", attr);
|
||||
string_list_append(&str_list, "cg", attr);
|
||||
_len += strlcpy(ext_shaders + _len, "cgp", sizeof(ext_shaders) - _len);
|
||||
if (ext_shaders[_len-1] != '\0')
|
||||
_len += strlcpy(ext_shaders + _len, "|", sizeof(ext_shaders) - _len);
|
||||
_len += strlcpy(ext_shaders + _len, "cg", sizeof(ext_shaders) - _len);
|
||||
}
|
||||
|
||||
if (video_shader_is_supported(RARCH_SHADER_GLSL))
|
||||
{
|
||||
string_list_append(&str_list, "glslp", attr);
|
||||
string_list_append(&str_list, "glsl", attr);
|
||||
if (ext_shaders[_len-1] != '\0')
|
||||
_len += strlcpy(ext_shaders + _len, "|", sizeof(ext_shaders) - _len);
|
||||
_len += strlcpy(ext_shaders + _len, "glslp", sizeof(ext_shaders) - _len);
|
||||
if (ext_shaders[_len-1] != '\0')
|
||||
_len += strlcpy(ext_shaders + _len, "|", sizeof(ext_shaders) - _len);
|
||||
_len += strlcpy(ext_shaders + _len, "glsl", sizeof(ext_shaders) - _len);
|
||||
}
|
||||
|
||||
if (video_shader_is_supported(RARCH_SHADER_SLANG))
|
||||
{
|
||||
string_list_append(&str_list, "slangp", attr);
|
||||
string_list_append(&str_list, "slang", attr);
|
||||
if (ext_shaders[_len-1] != '\0')
|
||||
_len += strlcpy(ext_shaders + _len, "|", sizeof(ext_shaders) - _len);
|
||||
_len += strlcpy(ext_shaders + _len, "slangp", sizeof(ext_shaders) - _len);
|
||||
if (ext_shaders[_len-1] != '\0')
|
||||
_len += strlcpy(ext_shaders + _len, "|", sizeof(ext_shaders) - _len);
|
||||
_len += strlcpy(ext_shaders + _len, "slang", sizeof(ext_shaders) - _len);
|
||||
}
|
||||
|
||||
string_list_join_concat(ext_shaders, sizeof(ext_shaders), &str_list, "|");
|
||||
string_list_deinitialize(&str_list);
|
||||
exts = ext_shaders;
|
||||
}
|
||||
break;
|
||||
@ -6946,16 +6947,16 @@ static bool retroarch_parse_input_and_config(
|
||||
case 'd':
|
||||
{
|
||||
unsigned new_port;
|
||||
unsigned id = 0;
|
||||
struct string_list *list = string_split(optarg, ":");
|
||||
char *tok, *save;
|
||||
int port = 0;
|
||||
unsigned id = 0;
|
||||
char *optarg_cpy = strdup(optarg);
|
||||
|
||||
if (list && list->size == 2)
|
||||
{
|
||||
port = (int)strtol(list->elems[0].data, NULL, 0);
|
||||
id = (unsigned)strtoul(list->elems[1].data, NULL, 0);
|
||||
}
|
||||
string_list_free(list);
|
||||
if ((tok = strtok_r(optarg_cpy, ":", &save)))
|
||||
port = (int)strtol(tok, NULL, 0);
|
||||
if ((tok = strtok_r(NULL, ":", &save)))
|
||||
id = (unsigned)strtoul(tok, NULL, 0);
|
||||
free(optarg_cpy);
|
||||
|
||||
if (port < 1 || port > MAX_USERS)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user