mirror of
https://github.com/libretro/RetroArch
synced 2025-03-26 02:37:23 +00:00
Add block_frames member to audio driver init function;
be more prudent with strdup
This commit is contained in:
parent
7d0056d422
commit
b20c9d870b
@ -361,6 +361,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
*settings->audio.device ? settings->audio.device : NULL,
|
||||
settings->audio.out_rate, &new_rate,
|
||||
settings->audio.latency,
|
||||
settings->audio.block_frames,
|
||||
current_audio))
|
||||
{
|
||||
RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n");
|
||||
@ -374,6 +375,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
current_audio->init(*settings->audio.device ?
|
||||
settings->audio.device : NULL,
|
||||
settings->audio.out_rate, settings->audio.latency,
|
||||
settings->audio.block_frames,
|
||||
&new_rate);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ typedef struct audio_driver
|
||||
* Returns: audio driver handle on success, otherwise NULL.
|
||||
**/
|
||||
void *(*init)(const char *device, unsigned rate,
|
||||
unsigned latency, unsigned *new_rate);
|
||||
unsigned latency, unsigned block_frames, unsigned *new_rate);
|
||||
|
||||
/*
|
||||
* @data : Pointer to audio data handle.
|
||||
|
@ -44,6 +44,7 @@ typedef struct audio_thread
|
||||
unsigned *new_rate;
|
||||
unsigned out_rate;
|
||||
unsigned latency;
|
||||
unsigned block_frames;
|
||||
} audio_thread_t;
|
||||
|
||||
static void audio_thread_loop(void *data)
|
||||
@ -54,7 +55,8 @@ static void audio_thread_loop(void *data)
|
||||
return;
|
||||
|
||||
RARCH_LOG("[Audio Thread]: Initializing audio driver.\n");
|
||||
thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency, thr->new_rate);
|
||||
thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency,
|
||||
thr->block_frames, thr->new_rate);
|
||||
slock_lock(thr->lock);
|
||||
thr->inited = thr->driver_data ? 1 : -1;
|
||||
if (thr->inited > 0 && thr->driver->use_float)
|
||||
@ -277,7 +279,8 @@ static const audio_driver_t audio_thread = {
|
||||
**/
|
||||
bool audio_init_thread(const audio_driver_t **out_driver,
|
||||
void **out_data, const char *device, unsigned audio_out_rate,
|
||||
unsigned *new_rate, unsigned latency, const audio_driver_t *drv)
|
||||
unsigned *new_rate, unsigned block_frames,
|
||||
unsigned latency, const audio_driver_t *drv)
|
||||
{
|
||||
audio_thread_t *thr = (audio_thread_t*)calloc(1, sizeof(*thr));
|
||||
if (!thr)
|
||||
@ -288,6 +291,7 @@ bool audio_init_thread(const audio_driver_t **out_driver,
|
||||
thr->out_rate = audio_out_rate;
|
||||
thr->new_rate = new_rate;
|
||||
thr->latency = latency;
|
||||
thr->block_frames = block_frames;
|
||||
|
||||
if (!(thr->cond = scond_new()))
|
||||
goto error;
|
||||
|
@ -39,6 +39,7 @@
|
||||
**/
|
||||
bool audio_init_thread(const audio_driver_t **out_driver, void **out_data,
|
||||
const char *device, unsigned out_rate, unsigned *new_rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
const audio_driver_t *driver);
|
||||
|
||||
#endif
|
||||
|
@ -54,6 +54,7 @@ static bool find_float_format(snd_pcm_t *pcm, void *data)
|
||||
}
|
||||
|
||||
static void *alsa_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
snd_pcm_format_t format;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <sys/asoundlib.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
|
||||
#define MAX_FRAG_SIZE 3072
|
||||
#define DEFAULT_RATE 48000
|
||||
@ -46,13 +45,13 @@ typedef struct alsa
|
||||
typedef long snd_pcm_sframes_t;
|
||||
|
||||
static void *alsa_qsa_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency, unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
int err, card, dev, i;
|
||||
snd_pcm_channel_info_t pi;
|
||||
snd_pcm_channel_params_t params = {0};
|
||||
snd_pcm_channel_setup_t setup = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
alsa_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t));
|
||||
if (!alsa)
|
||||
return NULL;
|
||||
@ -122,8 +121,8 @@ static void *alsa_qsa_init(const char *device,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (settings->audio.block_frames)
|
||||
alsa->buf_size = settings->audio.block_frames * 4;
|
||||
if (block_frames)
|
||||
alsa->buf_size = block_frames * 4;
|
||||
else
|
||||
alsa->buf_size = next_pow2(32 * latency);
|
||||
|
||||
|
@ -155,7 +155,9 @@ static void alsa_thread_free(void *data)
|
||||
}
|
||||
|
||||
static void *alsa_thread_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
snd_pcm_uframes_t buffer_size;
|
||||
snd_pcm_format_t format;
|
||||
|
@ -180,7 +180,9 @@ done:
|
||||
#endif
|
||||
|
||||
static void *coreaudio_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
size_t fifo_size;
|
||||
UInt32 i_size;
|
||||
|
@ -104,6 +104,7 @@ Result csndPlaySound_custom(int chn, u32 flags, float vol, float pan,
|
||||
}
|
||||
|
||||
static void *ctr_csnd_audio_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)calloc(1, sizeof(ctr_csnd_audio_t));
|
||||
|
@ -38,6 +38,7 @@ typedef struct
|
||||
#define CTR_DSP_AUDIO_SIZE_MASK (CTR_DSP_AUDIO_SIZE - 1u)
|
||||
|
||||
static void *ctr_dsp_audio_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
ctr_dsp_audio_t *ctr = NULL;
|
||||
|
@ -304,6 +304,7 @@ static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOI
|
||||
}
|
||||
|
||||
static void *dsound_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
WAVEFORMATEX wfx = {0};
|
||||
|
@ -68,7 +68,9 @@ static void dma_callback(void)
|
||||
}
|
||||
|
||||
static void *gx_audio_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
gx_audio_t *wa = (gx_audio_t*)memalign(32, sizeof(*wa));
|
||||
if (!wa)
|
||||
|
@ -150,6 +150,7 @@ static size_t find_buffersize(jack_t *jd, int latency, unsigned out_rate)
|
||||
}
|
||||
|
||||
static void *ja_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
int i;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "../../verbosity.h"
|
||||
|
||||
static void *null_audio_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
RARCH_ERR("Using the null audio driver. RetroArch will be silent.");
|
||||
|
@ -81,6 +81,7 @@ static void al_free(void *data)
|
||||
}
|
||||
|
||||
static void *al_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
al_t *al;
|
||||
|
@ -99,6 +99,7 @@ static void sl_free(void *data)
|
||||
}
|
||||
|
||||
static void *sl_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
unsigned i;
|
||||
@ -107,7 +108,6 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency,
|
||||
SLDataSink audio_sink = {0};
|
||||
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {0};
|
||||
SLDataLocator_OutputMix loc_outmix = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
SLresult res = 0;
|
||||
SLInterfaceID id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
|
||||
SLboolean req = SL_BOOLEAN_TRUE;
|
||||
@ -126,8 +126,8 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency,
|
||||
GOTO_IF_FAIL(SLEngineItf_CreateOutputMix(sl->engine, &sl->output_mix, 0, NULL, NULL));
|
||||
GOTO_IF_FAIL(SLObjectItf_Realize(sl->output_mix, SL_BOOLEAN_FALSE));
|
||||
|
||||
if (settings->audio.block_frames)
|
||||
sl->buf_size = settings->audio.block_frames * 4;
|
||||
if (block_frames)
|
||||
sl->buf_size = block_frames * 4;
|
||||
else
|
||||
sl->buf_size = next_pow2(32 * latency);
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
static bool oss_is_paused = false;
|
||||
|
||||
static void *oss_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_out_rate)
|
||||
{
|
||||
int frags, frag, channels, format, new_rate;
|
||||
|
@ -78,7 +78,9 @@ static void event_loop(uint64_t data)
|
||||
}
|
||||
|
||||
static void *ps3_audio_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
CellAudioPortParam params;
|
||||
ps3_audio_t *data = calloc(1, sizeof(*data));
|
||||
|
@ -119,7 +119,9 @@ static int audioMainLoop(SceSize args, void* argp)
|
||||
}
|
||||
|
||||
static void *psp_audio_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
psp_audio_t *psp = (psp_audio_t*)calloc(1, sizeof(psp_audio_t));
|
||||
|
||||
|
@ -148,7 +148,9 @@ static void buffer_attr_cb(pa_stream *s, void *data)
|
||||
}
|
||||
|
||||
static void *pulse_init(const char *device, unsigned rate,
|
||||
unsigned latency, unsigned *new_rate)
|
||||
unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
pa_sample_spec spec;
|
||||
pa_buffer_attr buffer_attr = {0};
|
||||
|
@ -32,7 +32,8 @@ typedef struct
|
||||
bool is_paused;
|
||||
} roar_t;
|
||||
|
||||
static void *ra_init(const char *device, unsigned rate, unsigned latency)
|
||||
static void *ra_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames, unsigned *new_rate)
|
||||
{
|
||||
int err;
|
||||
roar_vs_t *vss = NULL;
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <boolean.h>
|
||||
|
||||
#include "../audio_driver.h"
|
||||
#include "../../configuration.h"
|
||||
|
||||
/* forward declarations */
|
||||
unsigned RWebAudioSampleRate(void);
|
||||
@ -38,6 +37,7 @@ static void rwebaudio_free(void *data)
|
||||
}
|
||||
|
||||
static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
void *data = RWebAudioInit(latency);
|
||||
|
@ -66,7 +66,9 @@ static INLINE int find_num_frames(int rate, int latency)
|
||||
}
|
||||
|
||||
static void *sdl_audio_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
int frames;
|
||||
size_t bufsize;
|
||||
|
@ -85,6 +85,7 @@ void wiiu_ax_callback(void)
|
||||
extern void AXRegisterFrameCallback(void *cb);
|
||||
|
||||
static void* ax_audio_init(const char* device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
ax_audio_t* ax = (ax_audio_t*)calloc(1, sizeof(ax_audio_t));
|
||||
|
@ -235,6 +235,7 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_)
|
||||
}
|
||||
|
||||
static void *xa_init(const char *device, unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
size_t bufsize;
|
||||
|
@ -34,7 +34,9 @@ typedef struct
|
||||
} xenon_audio_t;
|
||||
|
||||
static void *xenon360_audio_init(const char *device,
|
||||
unsigned rate, unsigned latency, unsigned *new_rate)
|
||||
unsigned rate, unsigned latency,
|
||||
unsigned block_frames,
|
||||
unsigned *new_rate)
|
||||
{
|
||||
static bool inited = false;
|
||||
|
||||
|
35
core_info.c
35
core_info.c
@ -114,13 +114,13 @@ static void core_info_list_resolve_all_firmware(
|
||||
snprintf(desc_key, sizeof(desc_key), "firmware%u_desc", c);
|
||||
snprintf(opt_key, sizeof(opt_key), "firmware%u_opt", c);
|
||||
|
||||
if (config_get_string(config, path_key, &tmp))
|
||||
if (config_get_string(config, path_key, &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
info->firmware[c].path = strdup(tmp);
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
if (config_get_string(config, desc_key, &tmp))
|
||||
if (config_get_string(config, desc_key, &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
info->firmware[c].desc = strdup(tmp);
|
||||
free(tmp);
|
||||
@ -254,27 +254,27 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
if (!conf)
|
||||
continue;
|
||||
|
||||
if (config_get_string(conf, "display_name", &tmp))
|
||||
if (config_get_string(conf, "display_name", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].display_name = strdup(tmp);
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
if (config_get_string(conf, "corename", &tmp))
|
||||
if (config_get_string(conf, "corename", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].core_name = strdup(tmp);
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "systemname", &tmp))
|
||||
if (config_get_string(conf, "systemname", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].systemname = strdup(tmp);
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "manufacturer", &tmp))
|
||||
if (config_get_string(conf, "manufacturer", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].system_manufacturer = strdup(tmp);
|
||||
free(tmp);
|
||||
@ -285,7 +285,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
|
||||
core_info[i].firmware_count = count;
|
||||
|
||||
if (config_get_string(conf, "supported_extensions", &tmp))
|
||||
if (config_get_string(conf, "supported_extensions", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].supported_extensions = strdup(tmp);
|
||||
core_info[i].supported_extensions_list =
|
||||
@ -295,7 +295,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "authors", &tmp))
|
||||
if (config_get_string(conf, "authors", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].authors = strdup(tmp);
|
||||
core_info[i].authors_list =
|
||||
@ -305,7 +305,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "permissions", &tmp))
|
||||
if (config_get_string(conf, "permissions", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].permissions = strdup(tmp);
|
||||
core_info[i].permissions_list =
|
||||
@ -315,7 +315,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "license", &tmp))
|
||||
if (config_get_string(conf, "license", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].licenses = strdup(tmp);
|
||||
core_info[i].licenses_list =
|
||||
@ -325,7 +325,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "categories", &tmp))
|
||||
if (config_get_string(conf, "categories", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].categories = strdup(tmp);
|
||||
core_info[i].categories_list =
|
||||
@ -335,7 +335,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "database", &tmp))
|
||||
if (config_get_string(conf, "database", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].databases = strdup(tmp);
|
||||
core_info[i].databases_list =
|
||||
@ -345,7 +345,7 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (config_get_string(conf, "notes", &tmp))
|
||||
if (config_get_string(conf, "notes", &tmp) && !string_is_empty(tmp))
|
||||
{
|
||||
core_info[i].notes = strdup(tmp);
|
||||
core_info[i].note_list = string_split(core_info[i].notes, "|");
|
||||
@ -361,7 +361,8 @@ static core_info_list_t *core_info_list_new(const char *path)
|
||||
core_info[i].config_data = conf;
|
||||
}
|
||||
|
||||
core_info[i].path = strdup(contents->elems[i].data);
|
||||
if (!string_is_empty(contents->elems[i].data))
|
||||
core_info[i].path = strdup(contents->elems[i].data);
|
||||
|
||||
if (!core_info[i].display_name)
|
||||
core_info[i].display_name =
|
||||
@ -816,11 +817,15 @@ bool core_info_database_supports_content_path(const char *database_path, const c
|
||||
char *database = NULL;
|
||||
const char *delim = NULL;
|
||||
const char *archive_path = NULL;
|
||||
const char *new_path = NULL;
|
||||
|
||||
if (!core_info_curr_list)
|
||||
return false;
|
||||
|
||||
database = strdup(path_basename(database_path));
|
||||
new_path = path_basename(database_path);
|
||||
|
||||
if (!string_is_empty(new_path))
|
||||
database = strdup(new_path);
|
||||
|
||||
path_remove_extension(database);
|
||||
|
||||
|
15
dynamic.c
15
dynamic.c
@ -324,8 +324,11 @@ static bool libretro_get_system_info_static(struct retro_system_info *info,
|
||||
retro_get_system_info(&dummy_info);
|
||||
memcpy(info, &dummy_info, sizeof(*info));
|
||||
|
||||
info->library_name = strdup(dummy_info.library_name);
|
||||
info->library_version = strdup(dummy_info.library_version);
|
||||
if (!string_is_empty(dummy_info.library_name))
|
||||
info->library_name = strdup(dummy_info.library_name);
|
||||
if (!string_is_empty(dummy_info.library_version))
|
||||
info->library_version = strdup(dummy_info.library_version);
|
||||
|
||||
if (dummy_info.valid_extensions)
|
||||
info->valid_extensions = strdup(dummy_info.valid_extensions);
|
||||
return true;
|
||||
@ -356,11 +359,13 @@ bool libretro_get_system_info(const char *path,
|
||||
return false;
|
||||
|
||||
memcpy(info, &dummy_info, sizeof(*info));
|
||||
info->library_name = strdup(dummy_info.library_name);
|
||||
info->library_version = strdup(dummy_info.library_version);
|
||||
if (!string_is_empty(dummy_info.library_name))
|
||||
info->library_name = strdup(dummy_info.library_name);
|
||||
if (!string_is_empty(dummy_info.library_version))
|
||||
info->library_version = strdup(dummy_info.library_version);
|
||||
|
||||
if (dummy_info.valid_extensions)
|
||||
info->valid_extensions = strdup(dummy_info.valid_extensions);
|
||||
info->valid_extensions = strdup(dummy_info.valid_extensions);
|
||||
|
||||
dylib_close(lib);
|
||||
#else
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <file/file_path.h>
|
||||
#include <compat/strl.h>
|
||||
#include <compat/posix_string.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
@ -111,8 +112,11 @@ void cheat_manager_set_code(unsigned i, const char *str)
|
||||
cheat_manager_t *handle = cheat_manager_state;
|
||||
if (!handle)
|
||||
return;
|
||||
handle->cheats[i].code = strdup(str);
|
||||
handle->cheats[i].state = true;
|
||||
|
||||
if (!string_is_empty(str))
|
||||
handle->cheats[i].code = strdup(str);
|
||||
|
||||
handle->cheats[i].state = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,10 +255,10 @@ bool cheat_manager_load(const char *path)
|
||||
snprintf(code_key, sizeof(code_key), "cheat%u_code", i);
|
||||
snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i);
|
||||
|
||||
if (config_get_string(conf, desc_key, &tmp))
|
||||
if (config_get_string(conf, desc_key, &tmp) && !string_is_empty(tmp))
|
||||
cheat->cheats[i].desc = strdup(tmp);
|
||||
|
||||
if (config_get_string(conf, code_key, &tmp))
|
||||
if (config_get_string(conf, code_key, &tmp) && !string_is_empty(tmp))
|
||||
cheat->cheats[i].code = strdup(tmp);
|
||||
|
||||
if (config_get_bool(conf, enable_key, &tmp_bool))
|
||||
|
@ -37,27 +37,26 @@ static bool core_option_manager_parse_variable(
|
||||
char *config_val = NULL;
|
||||
struct core_option *option = (struct core_option*)&opt->opts[idx];
|
||||
|
||||
option->key = strdup(var->key);
|
||||
value = strdup(var->value);
|
||||
if (!string_is_empty(var->key))
|
||||
option->key = strdup(var->key);
|
||||
if (!string_is_empty(var->value))
|
||||
value = strdup(var->value);
|
||||
|
||||
desc_end = strstr(value, "; ");
|
||||
|
||||
if (!desc_end)
|
||||
{
|
||||
free(value);
|
||||
return false;
|
||||
}
|
||||
goto error;
|
||||
|
||||
*desc_end = '\0';
|
||||
option->desc = strdup(value);
|
||||
|
||||
val_start = desc_end + 2;
|
||||
option->vals = string_split(val_start, "|");
|
||||
if (!string_is_empty(value))
|
||||
option->desc = strdup(value);
|
||||
|
||||
val_start = desc_end + 2;
|
||||
option->vals = string_split(val_start, "|");
|
||||
|
||||
if (!option->vals)
|
||||
{
|
||||
free(value);
|
||||
return false;
|
||||
}
|
||||
goto error;
|
||||
|
||||
if (config_get_string(opt->conf, option->key, &config_val))
|
||||
{
|
||||
@ -78,6 +77,10 @@ static bool core_option_manager_parse_variable(
|
||||
free(value);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
free(value);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user