diff --git a/runahead/copy_load_info.c b/runahead/copy_load_info.c index bef383b162..337ff7b990 100644 --- a/runahead/copy_load_info.c +++ b/runahead/copy_load_info.c @@ -45,122 +45,6 @@ static struct retro_game_info* clone_retro_game_info(const return dest; } -#if 0 -/* for cloning the Special field, however, attempting - * to use this feature crashes retroarch */ -static void free_retro_subsystem_memory_info(struct - retro_subsystem_memory_info *dest) -{ - if (!dest) - return; - if (dest->extension) - free(dest->extension); - dest->extension = NULL; -} - -static void clone_retro_subsystem_memory_info(struct - retro_subsystem_memory_info* dest, - const struct retro_subsystem_memory_info *src) -{ - dest->extension = strcpy_alloc(src->extension); - dest->type = src->type; -} - -static void free_retro_subsystem_rom_info(struct - retro_subsystem_rom_info *dest) -{ - int i; - if (!dest) - return; - - if (dest->desc) - free(dest->desc); - if (dest->valid_extensions) - free(dest->valid_extensions); - dest->desc = NULL; - dest->valid_extensions = NULL; - - for (i = 0; i < dest->num_memory; i++) - free_retro_subsystem_memory_info((struct - retro_subsystem_memory_info*)&dest->memory[i]); - - if (dest->memory) - free(dest->memory); - dest->memory = NULL; -} - -static void clone_retro_subsystem_rom_info(struct - retro_subsystem_rom_info *dest, - const struct retro_subsystem_rom_info *src) -{ - int i; - retro_subsystem_memory_info *memory = NULL; - - dest->need_fullpath = src->need_fullpath; - dest->block_extract = src->block_extract; - dest->required = src->required; - dest->num_memory = src->num_memory; - dest->desc = strcpy_alloc(src->desc); - dest->valid_extensions = strcpy_alloc(src->valid_extensions); - - memory = (struct retro_subsystem_memory_info*)calloc(1, - dest->num_memory * sizeof(struct retro_subsystem_memory_info)); - - dest->memory = memory; - - for (i = 0; i < dest->num_memory; i++) - clone_retro_subsystem_memory_info(&memory[i], &src->memory[i]); -} - -static void free_retro_subsystem_info(struct retro_subsystem_info *dest) -{ - int i; - - if (!dest) - return; - - if (dest->desc) - free(dest->desc); - if (dest->ident) - free(dest->ident); - dest->desc = NULL; - dest->ident = NULL; - - for (i = 0; i < dest->num_roms; i++) - free_retro_subsystem_rom_info((struct - retro_subsystem_rom_info*)&dest->roms[i]); - - if (dest->roms) - free(dest->roms); - dest->roms = NULL; -} - -static retro_subsystem_info* clone_retro_subsystem_info(struct - const retro_subsystem_info *src) -{ - int i; - retro_subsystem_info *dest = NULL; - retro_subsystem_rom_info *roms = NULL; - - if (!src) - return NULL; - dest = (struct retro_subsystem_info*)calloc(1, - sizeof(struct retro_subsystem_info)); - dest->desc = strcpy_alloc(src->desc); - dest->ident = strcpy_alloc(src->ident); - dest->num_roms = src->num_roms; - dest->id = src->id; - roms = (struct retro_subsystem_rom_info*) - calloc(src->num_roms, sizeof(struct retro_subsystem_rom_info)); - dest->roms = roms; - - for (i = 0; i < src->num_roms; i++) - clone_retro_subsystem_rom_info(&roms[i], &src->roms[i]); - - return dest; -} -#endif - static void free_retro_ctx_load_content_info(struct retro_ctx_load_content_info *dest) { @@ -174,13 +58,6 @@ static void free_retro_ctx_load_content_info(struct dest->info = NULL; dest->content = NULL; - -#if 0 - free_retro_subsystem_info((retro_subsystem_info*)dest->special); - if (dest->special) - free(dest->special); - dest->special = NULL; -#endif } static struct retro_ctx_load_content_info @@ -203,9 +80,6 @@ static struct retro_ctx_load_content_info if (src->content) dest->content = string_list_clone(src->content); -#if 0 - dest->special = clone_retro_subsystem_info(src->special); -#endif return dest; } diff --git a/runahead/mylist.c b/runahead/mylist.c index 11b3f3d6b4..dc00fd9525 100644 --- a/runahead/mylist.c +++ b/runahead/mylist.c @@ -4,95 +4,101 @@ #include "mylist.h" #include "mem_util.h" -void mylist_resize(MyList *list, int newSize, bool runConstructor) +void mylist_resize(MyList *list, int new_size, bool run_constructor) { - int newCapacity; - int oldSize; + int new_capacity; + int old_size; int i; void *element = NULL; - if (newSize < 0) - newSize = 0; + if (new_size < 0) + new_size = 0; if (!list) return; - newCapacity = newSize; - oldSize = list->size; + new_capacity = new_size; + old_size = list->size; - if (newSize == oldSize) + if (new_size == old_size) return; - if (newSize > list->capacity) + if (new_size > list->capacity) { - if (newCapacity < list->capacity * 2) - newCapacity = list->capacity * 2; + if (new_capacity < list->capacity * 2) + new_capacity = list->capacity * 2; /* try to realloc */ - list->data = (void**)realloc((void*)list->data, newCapacity * sizeof(void*)); + list->data = (void**)realloc( + (void*)list->data, new_capacity * sizeof(void*)); - for (i = list->capacity; i < newCapacity; i++) + for (i = list->capacity; i < new_capacity; i++) list->data[i] = NULL; - list->capacity = newCapacity; + list->capacity = new_capacity; } - if (newSize <= list->size) + + if (new_size <= list->size) { - for (i = newSize; i < list->size; i++) + for (i = new_size; i < list->size; i++) { element = list->data[i]; if (element) { - list->Destructor(element); + list->destructor(element); list->data[i] = NULL; } } } else { - for (i = list->size; i < newSize; i++) + for (i = list->size; i < new_size; i++) { - if (runConstructor) - list->data[i] = list->Constructor(); + if (run_constructor) + list->data[i] = list->constructor(); else list->data[i] = NULL; } } - list->size = newSize; + + list->size = new_size; } void *mylist_add_element(MyList *list) { - int oldSize; + int old_size; if (!list) return NULL; - oldSize = list->size; - mylist_resize(list, oldSize + 1, true); - return list->data[oldSize]; + old_size = list->size; + mylist_resize(list, old_size + 1, true); + return list->data[old_size]; } -void mylist_create(MyList **list_p, int initialCapacity, +void mylist_create(MyList **list_p, int initial_capacity, constructor_t constructor, destructor_t destructor) { - MyList *list = NULL; + MyList *list = NULL; + if (!list_p) return; - if (initialCapacity < 0) - initialCapacity = 0; - list = *list_p; + + if (initial_capacity < 0) + initial_capacity = 0; + + list = *list_p; if (list) mylist_destroy(list_p); list = (MyList*)malloc(sizeof(MyList)); *list_p = list; list->size = 0; - list->Constructor = constructor; - list->Destructor = destructor; + list->constructor = constructor; + list->destructor = destructor; - if (initialCapacity > 0) + if (initial_capacity > 0) { - list->data = (void**)calloc(initialCapacity, sizeof(void*)); - list->capacity = initialCapacity; + list->data = (void**)calloc(initial_capacity, sizeof(void*)); + list->capacity = initial_capacity; } else { @@ -120,13 +126,13 @@ void mylist_destroy(MyList **list_p) void mylist_assign(MyList *list, int index, void *value) { - void *oldElement = NULL; + void *old_element = NULL; if (index < 0 || index >= list->size) return; - oldElement = list->data[index]; - list->Destructor(oldElement); + old_element = list->data[index]; + list->destructor(old_element); list->data[index] = value; } @@ -153,10 +159,10 @@ void mylist_pop_front(MyList *list) void mylist_push_back(MyList *list, void *value) { - int oldSize; + int old_size; if (!list) return; - oldSize = list->size; - mylist_resize(list, oldSize + 1, false); - list->data[oldSize] = value; + old_size = list->size; + mylist_resize(list, old_size + 1, false); + list->data[old_size] = value; } diff --git a/runahead/mylist.h b/runahead/mylist.h index ec0238912d..cdc03efab0 100644 --- a/runahead/mylist.h +++ b/runahead/mylist.h @@ -8,23 +8,23 @@ RETRO_BEGIN_DECLS -typedef void* (*constructor_t)(void); -typedef void(*destructor_t)(void*); +typedef void *(*constructor_t)(void); +typedef void (*destructor_t )(void*); typedef struct MyList_t { void **data; int capacity; int size; - constructor_t Constructor; - destructor_t Destructor; + constructor_t constructor; + destructor_t destructor; } MyList; void *mylist_add_element(MyList *list); -void mylist_resize(MyList *list, int newSize, bool runConstructor); +void mylist_resize(MyList *list, int newSize, bool run_constructor); -void mylist_create(MyList **list_p, int initialCapacity, +void mylist_create(MyList **list_p, int initial_capacity, constructor_t constructor, destructor_t destructor); void mylist_destroy(MyList **list_p);