JUst use strdup instead of strcpy_alloc
This commit is contained in:
parent
bb3e7fad66
commit
0421d463f8
46
retroarch.c
46
retroarch.c
|
@ -10709,30 +10709,12 @@ static void free_retro_ctx_load_content_info(struct
|
||||||
static struct retro_game_info* clone_retro_game_info(const
|
static struct retro_game_info* clone_retro_game_info(const
|
||||||
struct retro_game_info *src)
|
struct retro_game_info *src)
|
||||||
{
|
{
|
||||||
struct retro_game_info *dest = NULL;
|
struct retro_game_info *dest = (struct retro_game_info*)calloc(1,
|
||||||
|
|
||||||
if (!src)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dest = (struct retro_game_info*)calloc(1,
|
|
||||||
sizeof(struct retro_game_info));
|
sizeof(struct retro_game_info));
|
||||||
|
|
||||||
if (!dest)
|
if (!dest)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dest->data = NULL;
|
|
||||||
|
|
||||||
if (src->path)
|
|
||||||
{
|
|
||||||
size_t len = strlen(src->path);
|
|
||||||
|
|
||||||
if (len > 0)
|
|
||||||
{
|
|
||||||
char *result = (char*)malloc(len+1);
|
|
||||||
strcpy(result, src->path);
|
|
||||||
dest->path = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src->size && src->data)
|
if (src->size && src->data)
|
||||||
{
|
{
|
||||||
void *data = malloc(src->size);
|
void *data = malloc(src->size);
|
||||||
|
@ -10744,20 +10726,13 @@ static struct retro_game_info* clone_retro_game_info(const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string_is_empty(src->path))
|
||||||
|
dest->path = strdup(src->path);
|
||||||
|
if (!string_is_empty(src->meta))
|
||||||
|
dest->meta = strdup(src->meta);
|
||||||
|
|
||||||
dest->size = src->size;
|
dest->size = src->size;
|
||||||
|
|
||||||
if (src->meta)
|
|
||||||
{
|
|
||||||
size_t len = strlen(src->meta);
|
|
||||||
|
|
||||||
if (len > 0)
|
|
||||||
{
|
|
||||||
char *result = (char*)malloc(len+1);
|
|
||||||
strcpy(result, src->meta);
|
|
||||||
dest->meta = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10776,12 +10751,11 @@ static struct retro_ctx_load_content_info
|
||||||
if (!dest)
|
if (!dest)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dest->info = clone_retro_game_info(src->info);
|
if (src->info)
|
||||||
dest->content = NULL;
|
dest->info = clone_retro_game_info(src->info);
|
||||||
dest->special = NULL;
|
|
||||||
|
|
||||||
if (src->content)
|
if (src->content)
|
||||||
dest->content = string_list_clone(src->content);
|
dest->content = string_list_clone(src->content);
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue