Refactor away core_info_get_id

This commit is contained in:
Twinaphex 2014-07-21 02:46:01 +02:00
parent f64b772ceb
commit cb7ad2d6e6
4 changed files with 4 additions and 24 deletions

View File

@ -156,12 +156,10 @@ static char** waiting_argv;
for (i = 0; core_list && i < core_list->count; i ++)
{
char buf[PATH_MAX];
NSString* desc = (NSString*)BOXSTRING(core_list->list[i].display_name);
NSString *__core = BOXSTRING(core_info_get_id(&core_list->list[i], buf, sizeof(buf)));
#if defined(MAC_OS_X_VERSION_10_6)
/* FIXME - Rewrite this so that this is no longer an associated object - requires ObjC 2.0 runtime */
objc_setAssociatedObject(desc, associated_core_key, __core, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject(desc, associated_core_key, BOXSTRING(core_list->list[i].path), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
#endif
[cb addItemWithObjectValue:desc];
}

View File

@ -883,8 +883,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
for (i = 0; i < core_list->count; i ++)
{
char buf[PATH_MAX];
NSString* core_id = BOXSTRING(core_info_get_id(&core_list->list[i], buf, sizeof(buf)));
NSString* core_id = BOXSTRING(core_list->list[i].path);
if (core_info_has_custom_config(core_id.UTF8String))
{
@ -1092,16 +1091,13 @@ static bool copy_config(const char *src_path, const char *dst_path)
{
if (_path)
{
char buf[PATH_MAX];
const core_info_t* core_support = NULL;
size_t core_count = 0;
NSString *__core;
core_info_list_get_supported_cores(core_list, _path.UTF8String, &core_support, &core_count);
__core = BOXSTRING(core_info_get_id(&core_support[0], buf, sizeof(buf)));
if (core_count == 1 && _action)
[self runAction:__core];
[self runAction:BOXSTRING(core_support[0].path)];
else if (core_count > 1)
[self load:(uint32_t)core_count coresFromList:core_support toSection:core_section];
}
@ -1125,10 +1121,9 @@ static bool copy_config(const char *src_path, const char *dst_path)
- (void)load:(uint32_t)count coresFromList:(const core_info_t*)list toSection:(NSMutableArray*)array
{
int i;
char buf[PATH_MAX];
for (i = 0; i < count; i++)
[array addObject:[[RAMenuItemCoreList alloc] initWithCore:BOXSTRING(core_info_get_id(&list[i], buf, sizeof(buf))) parent:self]];
[array addObject:[[RAMenuItemCoreList alloc] initWithCore:BOXSTRING(list[i].path) parent:self]];
}
@end

View File

@ -472,18 +472,6 @@ const core_info_t *core_info_list_get_by_id(const char *core_id)
return 0;
}
const char *core_info_get_id(const core_info_t *info, char *buffer, size_t buffer_length)
{
if (!buffer || !buffer_length)
return "";
if (info && info->path && strlcpy(buffer, info->path, buffer_length) < buffer_length)
return buffer;
*buffer = 0;
return buffer;
}
const char *core_info_get_custom_config(const char *core_id, char *buffer, size_t buffer_length)
{
if (!core_id || !buffer || !buffer_length)

View File

@ -91,7 +91,6 @@ void core_info_set_config_path(const char *config_path);
core_info_list_t *core_info_list_get(void);
const core_info_t *core_info_list_get_by_id(const char *core_id);
const char *core_info_get_id(const core_info_t *info, char *buffer, size_t buffer_length);
const char *core_info_get_custom_config(const char *core_id, char *buffer, size_t buffer_length);
bool core_info_has_custom_config(const char *core_id);