mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 18:40:09 +00:00
(libretro-db) c_converter: merge list entries sharing the same key
instead of overwriting the old ones.
This commit is contained in:
parent
35e54b9777
commit
77e22e9a79
@ -129,6 +129,7 @@ static void dat_converter_list_free(dat_converter_list_t* list)
|
|||||||
free(list->values);
|
free(list->values);
|
||||||
free(list);
|
free(list);
|
||||||
}
|
}
|
||||||
|
static void dat_converter_list_append(dat_converter_list_t* dst, void* item);
|
||||||
|
|
||||||
static dat_converter_bt_node_t* dat_converter_bt_node_insert(dat_converter_list_t* list, dat_converter_bt_node_t** node,
|
static dat_converter_bt_node_t* dat_converter_bt_node_insert(dat_converter_list_t* list, dat_converter_bt_node_t** node,
|
||||||
dat_converter_map_t* map)
|
dat_converter_map_t* map)
|
||||||
@ -155,9 +156,21 @@ static dat_converter_bt_node_t* dat_converter_bt_node_insert(dat_converter_list_
|
|||||||
/* found match */
|
/* found match */
|
||||||
|
|
||||||
if (list->values[(*node)->index].map.type == DAT_CONVERTER_LIST_MAP)
|
if (list->values[(*node)->index].map.type == DAT_CONVERTER_LIST_MAP)
|
||||||
dat_converter_list_free(list->values[(*node)->index].map.value.list);
|
{
|
||||||
|
if (map->type == DAT_CONVERTER_LIST_MAP)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
assert(list->values[(*node)->index].map.value.list->type == map->value.list->type);
|
||||||
|
for (i = 0; i < map->value.list->count; i++)
|
||||||
|
dat_converter_list_append(list->values[(*node)->index].map.value.list, &map->value.list->values[i]);
|
||||||
|
|
||||||
list->values[(*node)->index].map = *map;
|
/* set count to 0 to prevent freeing the child nodes */
|
||||||
|
map->value.list->count = 0;
|
||||||
|
dat_converter_list_free(map->value.list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
list->values[(*node)->index].map = *map;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -630,30 +643,32 @@ static int dat_converter_value_provider(dat_converter_list_item_t** current_item
|
|||||||
current->value.type = RDT_BINARY;
|
current->value.type = RDT_BINARY;
|
||||||
current->value.val.binary.len = strlen(value) / 2;
|
current->value.val.binary.len = strlen(value) / 2;
|
||||||
current->value.val.binary.buff = malloc(current->value.val.binary.len);
|
current->value.val.binary.buff = malloc(current->value.val.binary.len);
|
||||||
const char* hex_char = value;
|
|
||||||
char* out_buff = current->value.val.binary.buff;
|
|
||||||
while (*hex_char && *(hex_char + 1))
|
|
||||||
{
|
{
|
||||||
char val = 0;
|
const char* hex_char = value;
|
||||||
if (*hex_char >= 'A' && *hex_char <= 'F')
|
char* out_buff = current->value.val.binary.buff;
|
||||||
val = *hex_char + 0xA - 'A';
|
while (*hex_char && *(hex_char + 1))
|
||||||
else if (*hex_char >= 'a' && *hex_char <= 'f')
|
{
|
||||||
val = *hex_char + 0xA - 'a';
|
char val = 0;
|
||||||
else if (*hex_char >= '0' && *hex_char <= '9')
|
if (*hex_char >= 'A' && *hex_char <= 'F')
|
||||||
val = *hex_char - '0';
|
val = *hex_char + 0xA - 'A';
|
||||||
else
|
else if (*hex_char >= 'a' && *hex_char <= 'f')
|
||||||
val = 0;
|
val = *hex_char + 0xA - 'a';
|
||||||
val <<= 4;
|
else if (*hex_char >= '0' && *hex_char <= '9')
|
||||||
hex_char++;
|
val = *hex_char - '0';
|
||||||
if (*hex_char >= 'A' && *hex_char <= 'F')
|
else
|
||||||
val |= *hex_char + 0xA - 'A';
|
val = 0;
|
||||||
else if (*hex_char >= 'a' && *hex_char <= 'f')
|
val <<= 4;
|
||||||
val |= *hex_char + 0xA - 'a';
|
hex_char++;
|
||||||
else if (*hex_char >= '0' && *hex_char <= '9')
|
if (*hex_char >= 'A' && *hex_char <= 'F')
|
||||||
val |= *hex_char - '0';
|
val |= *hex_char + 0xA - 'A';
|
||||||
|
else if (*hex_char >= 'a' && *hex_char <= 'f')
|
||||||
|
val |= *hex_char + 0xA - 'a';
|
||||||
|
else if (*hex_char >= '0' && *hex_char <= '9')
|
||||||
|
val |= *hex_char - '0';
|
||||||
|
|
||||||
*out_buff++ = val;
|
*out_buff++ = val;
|
||||||
hex_char++;
|
hex_char++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user