Merge runahead/mem_util.c into retroarch.c

This commit is contained in:
twinaphex 2020-01-31 02:32:49 +01:00
parent 982e35db45
commit 12da79730f
6 changed files with 47 additions and 73 deletions

View File

@ -278,8 +278,7 @@ endif
ifeq ($(HAVE_RUNAHEAD), 1)
DEFINES += -DHAVE_RUNAHEAD
OBJ += runahead/mem_util.o \
runahead/mylist.o
OBJ += runahead/mylist.o
endif
ifeq ($(HAVE_CC_RESAMPLER), 1)

View File

@ -1386,7 +1386,6 @@ MENU
#endif
#ifdef HAVE_RUNAHEAD
#include "../runahead/mem_util.c"
#include "../runahead/mylist.c"
#endif

View File

@ -225,7 +225,6 @@
#ifdef HAVE_RUNAHEAD
#include "runahead/mylist.h"
#include "runahead/mem_util.h"
#endif
#ifdef HAVE_ACCESSIBILITY
@ -3501,6 +3500,52 @@ static const void *hid_data = NULL;
static enum rarch_core_type last_core_type;
static retro_ctx_load_content_info_t *load_content_info;
static char *strcpy_alloc(const char *src)
{
char *result = NULL;
size_t len = src ? strlen(src) : 0;
if (len == 0)
return NULL;
result = (char*)malloc(len + 1);
strcpy(result, src);
return result;
}
static char *strcpy_alloc_force(const char *src)
{
char *result = strcpy_alloc(src);
if (!result)
return (char*)calloc(1, 1);
return result;
}
static void strcat_alloc(char **dst, const char *s)
{
size_t len1;
char *src = *dst;
if (!src)
{
src = strcpy_alloc_force(s);
*dst = src;
return;
}
if (!s)
return;
len1 = strlen(src);
src = (char*)realloc(src, len1 + strlen(s) + 1);
if (!src)
return;
*dst = src;
strcpy(src + len1, s);
}
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
/* Forward declarations */
static bool secondary_core_create(void);

View File

@ -1,49 +0,0 @@
#include <stdlib.h>
#include "mem_util.h"
static char *strcpy_alloc(const char *src)
{
char *result = NULL;
size_t len = src ? strlen(src) : 0;
if (len == 0)
return NULL;
result = (char*)malloc(len + 1);
strcpy(result, src);
return result;
}
char *strcpy_alloc_force(const char *src)
{
char *result = strcpy_alloc(src);
if (!result)
return (char*)calloc(1, 1);
return result;
}
void strcat_alloc(char **dst, const char *s)
{
size_t len1;
char *src = *dst;
if (!src)
{
src = strcpy_alloc_force(s);
*dst = src;
return;
}
if (!s)
return;
len1 = strlen(src);
src = (char*)realloc(src, len1 + strlen(s) + 1);
if (!src)
return;
*dst = src;
strcpy(src + len1, s);
}

View File

@ -1,19 +0,0 @@
#ifndef __MEM_UTIL__
#define __MEM_UTIL__
#include <stddef.h>
#include <string.h>
#include <boolean.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
char *strcpy_alloc_force(const char *sourceStr);
void strcat_alloc(char ** destStr_p, const char *appendStr);
RETRO_END_DECLS
#endif

View File

@ -2,7 +2,6 @@
#include <string.h>
#include "mylist.h"
#include "mem_util.h"
void mylist_resize(MyList *list, int new_size, bool run_constructor)
{