Style nits

This commit is contained in:
LibretroAdmin 2025-01-19 22:15:34 +01:00
parent 13bc41facc
commit 3549d8378c
22 changed files with 262 additions and 402 deletions

View File

@ -99,7 +99,7 @@ static void audio_thread_loop(void *data)
thr->driver->stop(thr->driver_data);
while (thr->stopped)
{
/* If we stop right after start,
/* If we stop right after start,
* we might not be able to properly ack.
* Signal in the loop instead. */
thr->stopped_ack = true;
@ -249,7 +249,7 @@ static bool audio_thread_use_float(void *data)
return thr->use_float;
}
static ssize_t audio_thread_write(void *data, const void *buf, size_t size)
static ssize_t audio_thread_write(void *data, const void *s, size_t len)
{
ssize_t ret;
audio_thread_t *thr = (audio_thread_t*)data;
@ -257,7 +257,7 @@ static ssize_t audio_thread_write(void *data, const void *buf, size_t size)
if (!thr)
return 0;
ret = thr->driver->write(thr->driver_data, buf, size);
ret = thr->driver->write(thr->driver_data, s, len);
if (ret < 0)
{

View File

@ -163,29 +163,29 @@ static bool al_get_buffer(al_t *al, ALuint *buffer)
return true;
}
static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size)
static size_t al_fill_internal_buf(al_t *al, const void *s, size_t len)
{
size_t read_size = MIN(OPENAL_BUFSIZE - al->tmpbuf_ptr, size);
memcpy(al->tmpbuf + al->tmpbuf_ptr, buf, read_size);
size_t read_size = MIN(OPENAL_BUFSIZE - al->tmpbuf_ptr, len);
memcpy(al->tmpbuf + al->tmpbuf_ptr, s, read_size);
al->tmpbuf_ptr += read_size;
return read_size;
}
static ssize_t al_write(void *data, const void *buf_, size_t size)
static ssize_t al_write(void *data, const void *s, size_t len)
{
al_t *al = (al_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
const uint8_t *buf = (const uint8_t*)s;
size_t written = 0;
while (size)
while (len)
{
ALint val;
ALuint buffer;
size_t rc = al_fill_internal_buf(al, buf, size);
size_t rc = al_fill_internal_buf(al, buf, len);
written += rc;
buf += rc;
size -= rc;
len -= rc;
if (al->tmpbuf_ptr != OPENAL_BUFSIZE)
break;
@ -254,11 +254,7 @@ static size_t al_buffer_size(void *data)
return (al->num_buffers + 1) * OPENAL_BUFSIZE; /* Also got tmpbuf. */
}
static bool al_use_float(void *data)
{
(void)data;
return false;
}
static bool al_use_float(void *data) { return false; }
audio_driver_t audio_openal = {
al_init,

View File

@ -232,13 +232,13 @@ static bool sl_start(void *data, bool is_shutdown)
return sl->is_paused ? false : true;
}
static ssize_t sl_write(void *data, const void *buf_, size_t size)
static ssize_t sl_write(void *data, const void *s, size_t len)
{
sl_t *sl = (sl_t*)data;
size_t written = 0;
const uint8_t *buf = (const uint8_t*)buf_;
const uint8_t *buf = (const uint8_t*)s;
while (size)
while (len)
{
size_t avail_write;
@ -255,14 +255,14 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
slock_unlock(sl->lock);
}
avail_write = MIN(sl->buf_size - sl->buffer_ptr, size);
avail_write = MIN(sl->buf_size - sl->buffer_ptr, len);
if (avail_write)
{
memcpy(sl->buffer[sl->buffer_index] + sl->buffer_ptr, buf, avail_write);
sl->buffer_ptr += avail_write;
buf += avail_write;
size -= avail_write;
len -= avail_write;
written += avail_write;
}
@ -287,8 +287,7 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
static size_t sl_write_avail(void *data)
{
sl_t *sl = (sl_t*)data;
size_t avail = (sl->buf_count - (int)sl->buffered_blocks - 1) * sl->buf_size + (sl->buf_size - (int)sl->buffer_ptr);
return avail;
return ((sl->buf_count - (int)sl->buffered_blocks - 1) * sl->buf_size + (sl->buf_size - (int)sl->buffer_ptr));
}
static size_t sl_buffer_size(void *data)
@ -297,11 +296,7 @@ static size_t sl_buffer_size(void *data)
return sl->buf_size * sl->buf_count;
}
static bool sl_use_float(void *data)
{
(void)data;
return false;
}
static bool sl_use_float(void *data) { return false; }
audio_driver_t audio_opensl = {
sl_init,

View File

@ -276,11 +276,31 @@ error:
return NULL;
}
static bool pulse_start(void *data, bool is_shutdown);
static ssize_t pulse_write(void *data, const void *buf_, size_t size)
static bool pulse_start(void *data, bool is_shutdown)
{
bool ret;
pa_t *pa = (pa_t*)data;
if (!pa->is_ready)
return false;
if (!pa->is_paused)
return true;
pa->success = true; /* In case of spurious wakeup. Not critical. */
pa_threaded_mainloop_lock(pa->mainloop);
pa_stream_cork(pa->stream, false, stream_success_cb, pa);
pa_threaded_mainloop_wait(pa->mainloop);
ret = pa->success;
pa_threaded_mainloop_unlock(pa->mainloop);
pa->is_paused = false;
return ret;
}
static ssize_t pulse_write(void *data, const void *s, size_t len)
{
pa_t *pa = (pa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
const uint8_t *buf = (const uint8_t*)s;
size_t written = 0;
/* Workaround buggy menu code.
@ -293,15 +313,15 @@ static ssize_t pulse_write(void *data, const void *buf_, size_t size)
return 0;
pa_threaded_mainloop_lock(pa->mainloop);
while (size)
while (len)
{
size_t writable = MIN(size, pa_stream_writable_size(pa->stream));
size_t writable = MIN(len, pa_stream_writable_size(pa->stream));
if (writable)
{
pa_stream_write(pa->stream, buf, writable, NULL, 0, PA_SEEK_RELATIVE);
buf += writable;
size -= writable;
buf += writable;
len -= writable;
written += writable;
}
else if (!pa->nonblock)
@ -344,26 +364,6 @@ static bool pulse_alive(void *data)
return !pa->is_paused;
}
static bool pulse_start(void *data, bool is_shutdown)
{
bool ret;
pa_t *pa = (pa_t*)data;
if (!pa->is_ready)
return false;
if (!pa->is_paused)
return true;
pa->success = true; /* In case of spurious wakeup. Not critical. */
pa_threaded_mainloop_lock(pa->mainloop);
pa_stream_cork(pa->stream, false, stream_success_cb, pa);
pa_threaded_mainloop_wait(pa->mainloop);
ret = pa->success;
pa_threaded_mainloop_unlock(pa->mainloop);
pa->is_paused = false;
return ret;
}
static void pulse_set_nonblock_state(void *data, bool state)
{
pa_t *pa = (pa_t*)data;
@ -371,11 +371,7 @@ static void pulse_set_nonblock_state(void *data, bool state)
pa->nonblock = state;
}
static bool pulse_use_float(void *data)
{
(void)data;
return true;
}
static bool pulse_use_float(void *data) { return true; }
static size_t pulse_write_avail(void *data)
{

View File

@ -286,7 +286,7 @@ int rsd_stop (rsound_t *rd);
or there was an unexpected error. This function will block until all data has
been written to the buffer. This function will return the number of bytes written to the buffer,
or 0 should it fail (disconnection from server). You will have to restart the stream again should this occur. */
size_t rsd_write (rsound_t *rd, const void* buf, size_t size);
size_t rsd_write (rsound_t *rd, const void *s, size_t len);
/* Gets the position of the buffer pointer.
Not really interesting for normal applications.

View File

@ -23,7 +23,7 @@
/* forward declarations */
unsigned RWebAudioSampleRate(void);
void *RWebAudioInit(unsigned latency);
ssize_t RWebAudioWrite(const void *buf, size_t size);
ssize_t RWebAudioWrite(const void *s, size_t len);
bool RWebAudioStop(void);
bool RWebAudioStart(void);
void RWebAudioSetNonblockState(bool state);
@ -54,9 +54,9 @@ static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency,
return rwebaudio;
}
static ssize_t rwebaudio_write(void *data, const void *buf, size_t size)
static ssize_t rwebaudio_write(void *data, const void *s, size_t len)
{
return RWebAudioWrite(buf, size);
return RWebAudioWrite(s, len);
}
static bool rwebaudio_stop(void *data)

View File

@ -282,7 +282,7 @@ static size_t libnx_audren_thread_audio_buffer_size(void *data)
}
static ssize_t libnx_audren_thread_audio_write(void *data,
const void *buf, size_t len)
const void *s, size_t len)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
size_t available, written, written_tmp;
@ -299,7 +299,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
available = FIFO_WRITE_AVAIL(aud->fifo);
written = MIN(available, len);
if (written > 0)
fifo_write(aud->fifo, buf, written);
fifo_write(aud->fifo, s, written);
mutexUnlock(&aud->fifo_lock);
}
else
@ -312,7 +312,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
if (available)
{
written_tmp = MIN(len - written, available);
fifo_write(aud->fifo, (const char*)buf + written, written_tmp);
fifo_write(aud->fifo, (const char*)s + written, written_tmp);
mutexUnlock(&aud->fifo_lock);
written += written_tmp;
}

View File

@ -49,7 +49,7 @@ struct core_backup_list
static bool core_backup_get_backup_dir(
const char *dir_libretro, const char *dir_core_assets,
const char *core_filename,
char *backup_dir, size_t len)
char *s, size_t len)
{
char tmp[PATH_MAX_LENGTH];
char core_file_id[NAME_MAX_LENGTH];
@ -87,18 +87,18 @@ static bool core_backup_get_backup_dir(
: dir_core_assets,
"core_backups", sizeof(tmp));
fill_pathname_join_special(backup_dir, tmp,
fill_pathname_join_special(s, tmp,
core_file_id, len);
if (string_is_empty(backup_dir))
if (string_is_empty(s))
return false;
/* > Create directory, if required */
if (!path_is_directory(backup_dir))
if (!path_is_directory(s))
{
if (!path_mkdir(backup_dir))
if (!path_mkdir(s))
{
RARCH_ERR("[core backup] Failed to create backup directory: %s.\n", backup_dir);
RARCH_ERR("[core backup] Failed to create backup directory: %s.\n", s);
return false;
}
}
@ -112,7 +112,7 @@ bool core_backup_get_backup_path(
const char *core_path, uint32_t crc,
enum core_backup_mode backup_mode,
const char *dir_core_assets,
char *backup_path, size_t len)
char *s, size_t len)
{
time_t current_time;
struct tm time_info;
@ -162,7 +162,7 @@ bool core_backup_get_backup_path(
FILE_PATH_CORE_BACKUP_EXTENSION);
/* Build final path */
fill_pathname_join_special(backup_path, backup_dir,
fill_pathname_join_special(s, backup_dir,
backup_filename, len);
return true;
@ -239,27 +239,25 @@ error:
/* Fetches crc value of specified core backup file.
* Returns true if successful */
bool core_backup_get_backup_crc(char *backup_path, uint32_t *crc)
bool core_backup_get_backup_crc(char *s, uint32_t *crc)
{
enum core_backup_type backup_type;
struct string_list *metadata_list = NULL;
if (string_is_empty(backup_path) || !crc)
if (string_is_empty(s) || !crc)
return false;
/* Get backup type */
backup_type = core_backup_get_backup_type(backup_path);
backup_type = core_backup_get_backup_type(s);
switch (backup_type)
{
case CORE_BACKUP_TYPE_ARCHIVE:
{
const char *backup_filename = NULL;
const char *crc_str = NULL;
/* Split the backup filename into its various
* metadata components */
backup_filename = path_basename(backup_path);
const char *backup_filename = path_basename(s);
if (string_is_empty(backup_filename))
goto error;
@ -293,7 +291,7 @@ bool core_backup_get_backup_crc(char *backup_path, uint32_t *crc)
/* Open backup file */
backup_file = intfstream_open_file(
backup_path, RETRO_VFS_FILE_ACCESS_READ,
s, RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (backup_file)
@ -334,7 +332,7 @@ error:
* arguments are otherwise invalid */
enum core_backup_type core_backup_get_core_path(
const char *backup_path, const char *dir_libretro,
char *core_path, size_t len)
char *s, size_t len)
{
const char *backup_filename = NULL;
@ -378,14 +376,14 @@ enum core_backup_type core_backup_get_core_path(
}
/* All good - build core path */
fill_pathname_join_special(core_path, dir_libretro,
fill_pathname_join_special(s, dir_libretro,
core_filename, len);
free(core_filename);
}
return CORE_BACKUP_TYPE_ARCHIVE;
case CORE_BACKUP_TYPE_LIB:
/* This is a plain dynamic library file */
fill_pathname_join_special(core_path, dir_libretro,
fill_pathname_join_special(s, dir_libretro,
backup_filename, len);
return CORE_BACKUP_TYPE_LIB;
default:

View File

@ -798,7 +798,7 @@ core_option_manager_t *core_option_manager_new_vars(
const struct retro_variable *vars)
{
const struct retro_variable *var = NULL;
size_t size = 0;
size_t _len = 0;
config_file_t *config_src = NULL;
core_option_manager_t *opt = NULL;
@ -837,29 +837,29 @@ core_option_manager_t *core_option_manager_new_vars(
/* Get number of variables */
for (var = vars; var->key && var->value; var++)
size++;
_len++;
if (size == 0)
if (_len == 0)
goto error;
/* Create options array */
if (!(opt->opts = (struct core_option*)calloc(size, sizeof(*opt->opts))))
if (!(opt->opts = (struct core_option*)calloc(_len, sizeof(*opt->opts))))
goto error;
opt->size = size;
size = 0;
opt->size = _len;
_len = 0;
/* Parse each variable */
for (var = vars; var->key && var->value; size++, var++)
for (var = vars; var->key && var->value; _len++, var++)
{
if (core_option_manager_parse_variable(opt, size, var, config_src))
if (core_option_manager_parse_variable(opt, _len, var, config_src))
{
size_t _len = 0;
size_t __len = 0;
/* If variable is read correctly, add it to
* the map */
char address[256];
address[ _len] = '#';
address[++_len] = '\0';
address[ __len] = '#';
address[++__len] = '\0';
/* Address string is normally:
* <category_key><delim><tag><option_key>
@ -869,10 +869,10 @@ core_option_manager_t *core_option_manager_new_vars(
* so we could just set the address to
* <option_key> - but for consistency with
* 'modern' options, we apply the tag regardless */
strlcpy(address + _len, var->key, sizeof(address) - _len);
strlcpy(address + __len, var->key, sizeof(address) - __len);
if (!nested_list_add_item(opt->option_map,
address, NULL, (const void*)&opt->opts[size]))
address, NULL, (const void*)&opt->opts[_len]))
goto error;
}
else
@ -1085,12 +1085,12 @@ core_option_manager_t *core_option_manager_new(
struct retro_core_option_v2_category *option_cats = NULL;
struct retro_core_option_v2_definition *option_defs = NULL;
size_t cats_size = 0;
size_t size = 0;
size_t _len = 0;
config_file_t *config_src = NULL;
core_option_manager_t *opt = NULL;
if (!options_v2 ||
!options_v2->definitions)
if ( !options_v2
|| !options_v2->definitions)
return NULL;
option_cats = options_v2->categories;
@ -1139,15 +1139,15 @@ core_option_manager_t *core_option_manager_new(
for (option_def = option_defs;
option_def->key && option_def->desc && option_def->values[0].value;
option_def++)
size++;
_len++;
if (size == 0)
if (_len == 0)
goto error;
/* Create categories array */
if (cats_size > 0)
{
if (!(opt->cats = (struct core_category*)calloc(size,
if (!(opt->cats = (struct core_category*)calloc(_len,
sizeof(*opt->cats))))
goto error;
@ -1171,23 +1171,23 @@ core_option_manager_t *core_option_manager_new(
}
/* Create options array */
if (!(opt->opts = (struct core_option*)calloc(size, sizeof(*opt->opts))))
if (!(opt->opts = (struct core_option*)calloc(_len, sizeof(*opt->opts))))
goto error;
opt->size = size;
size = 0;
opt->size = _len;
_len = 0;
/* Parse each option
* > Note: 'option_def->info == NULL' is valid */
for (option_def = option_defs;
option_def->key && option_def->desc && option_def->values[0].value;
size++, option_def++)
_len++, option_def++)
{
if (core_option_manager_parse_option(opt, size, option_def, config_src))
if (core_option_manager_parse_option(opt, _len, option_def, config_src))
{
/* If option is read correctly, add it to
* the map */
const char *category_key = opt->opts[size].category_key;
const char *category_key = opt->opts[_len].category_key;
char address[256];
/* Address string is nominally:
@ -1197,23 +1197,23 @@ core_option_manager_t *core_option_manager_new(
* collisions */
if (string_is_empty(category_key))
{
size_t _len = 0;
address[ _len] = '#';
address[++_len] = '\0';
strlcpy(address + _len, option_def->key, sizeof(address) - _len);
size_t __len = 0;
address[ __len] = '#';
address[++__len] = '\0';
strlcpy(address + __len, option_def->key, sizeof(address) - __len);
}
else
{
size_t _len = strlcpy(address, category_key, sizeof(address));
address[ _len] = ':';
address[++_len] = '#';
address[++_len] = '\0';
strlcpy(address + _len, option_def->key, sizeof(address) - _len);
size_t __len = strlcpy(address, category_key, sizeof(address));
address[ __len] = ':';
address[++__len] = '#';
address[++__len] = '\0';
strlcpy(address + __len, option_def->key, sizeof(address) - __len);
}
if (!nested_list_add_item(opt->option_map,
address, ":",
(const void*)&opt->opts[size]))
(const void*)&opt->opts[_len]))
goto error;
}
else

View File

@ -59,9 +59,9 @@ void libretro_dummy_retro_run(void);
size_t libretro_dummy_retro_serialize_size(void);
bool libretro_dummy_retro_serialize(void *data, size_t len);
bool libretro_dummy_retro_serialize(void *s, size_t len);
bool libretro_dummy_retro_unserialize(const void *data, size_t len);
bool libretro_dummy_retro_unserialize(const void *s, size_t len);
void libretro_dummy_retro_cheat_reset(void);
@ -113,9 +113,9 @@ void libretro_ffmpeg_retro_run(void);
size_t libretro_ffmpeg_retro_serialize_size(void);
bool libretro_ffmpeg_retro_serialize(void *data, size_t len);
bool libretro_ffmpeg_retro_serialize(void *s, size_t len);
bool libretro_ffmpeg_retro_unserialize(const void *data, size_t len);
bool libretro_ffmpeg_retro_unserialize(const void *s, size_t len);
void libretro_ffmpeg_retro_cheat_reset(void);

View File

@ -181,10 +181,6 @@ void IMAGE_CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb)
IMAGE_CORE_PREFIX(video_cb) = cb;
}
void IMAGE_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t unused)
{
}
void IMAGE_CORE_PREFIX(retro_set_audio_sample_batch)(retro_audio_sample_batch_t cb)
{
IMAGE_CORE_PREFIX(audio_batch_cb) = cb;
@ -200,41 +196,14 @@ void IMAGE_CORE_PREFIX(retro_set_input_state)(retro_input_state_t cb)
IMAGE_CORE_PREFIX(input_state_cb) = cb;
}
void IMAGE_CORE_PREFIX(retro_set_controller_port_device)(unsigned a, unsigned b)
{
}
void IMAGE_CORE_PREFIX(retro_reset)(void)
{
image_uploaded = false;
}
size_t IMAGE_CORE_PREFIX(retro_serialize_size)(void)
{
return 0;
}
bool IMAGE_CORE_PREFIX(retro_serialize)(void *data, size_t size)
{
(void)data;
(void)size;
return false;
}
bool IMAGE_CORE_PREFIX(retro_unserialize)(const void *data, size_t size)
{
(void)data;
(void)size;
return false;
}
void IMAGE_CORE_PREFIX(retro_cheat_reset)(void)
{
}
void IMAGE_CORE_PREFIX(retro_cheat_set)(unsigned a, bool b, const char * c)
{
}
void IMAGE_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t unused) { }
void IMAGE_CORE_PREFIX(retro_set_controller_port_device)(unsigned a, unsigned b) { }
void IMAGE_CORE_PREFIX(retro_reset)(void) { image_uploaded = false; }
size_t IMAGE_CORE_PREFIX(retro_serialize_size)(void) { return 0; }
bool IMAGE_CORE_PREFIX(retro_serialize)(void *data, size_t len) { return false; }
bool IMAGE_CORE_PREFIX(retro_unserialize)(const void *s, size_t len) { return false; }
void IMAGE_CORE_PREFIX(retro_cheat_reset)(void) { }
void IMAGE_CORE_PREFIX(retro_cheat_set)(unsigned a, bool b, const char * c) { }
static bool imageviewer_load(const char *path, int image_index)
{
@ -307,10 +276,12 @@ bool IMAGE_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)
return true;
}
bool IMAGE_CORE_PREFIX(retro_load_game_special)(unsigned a, const struct retro_game_info *b, size_t c)
{
return false;
}
bool IMAGE_CORE_PREFIX(retro_load_game_special)(unsigned a,
const struct retro_game_info *b, size_t c) { return false; }
unsigned IMAGE_CORE_PREFIX(retro_get_region)(void) { return RETRO_REGION_NTSC; }
void *IMAGE_CORE_PREFIX(retro_get_memory_data)(unsigned id) { return NULL; }
size_t IMAGE_CORE_PREFIX(retro_get_memory_size)(unsigned id) { return 0; }
void IMAGE_CORE_PREFIX(retro_unload_game)(void)
{
@ -319,21 +290,6 @@ void IMAGE_CORE_PREFIX(retro_unload_game)(void)
image_height = 0;
}
unsigned IMAGE_CORE_PREFIX(retro_get_region)(void)
{
return RETRO_REGION_NTSC;
}
void *IMAGE_CORE_PREFIX(retro_get_memory_data)(unsigned id)
{
return NULL;
}
size_t IMAGE_CORE_PREFIX(retro_get_memory_size)(unsigned id)
{
return 0;
}
void IMAGE_CORE_PREFIX(retro_run)(void)
{
bool first_image = false;

View File

@ -61,7 +61,7 @@ static char *filepath = NULL;
static volatile int frame_queue = 0;
void on_mpv_redraw(void *cb_ctx)
static void on_mpv_redraw(void *cb_ctx)
{
frame_queue++;
}
@ -395,10 +395,6 @@ void CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb)
CORE_PREFIX(video_cb) = cb;
}
void CORE_PREFIX(retro_reset)(void)
{
}
static void audio_callback(double fps)
{
/* Obtain len samples to reduce lag. */
@ -587,20 +583,9 @@ void CORE_PREFIX(retro_run)(void)
}
/* No save-state support */
size_t CORE_PREFIX(retro_serialize_size)(void)
{
return 0;
}
bool CORE_PREFIX(retro_serialize)(void *data_, size_t size)
{
return true;
}
bool CORE_PREFIX(retro_unserialize)(const void *data_, size_t size)
{
return true;
}
size_t CORE_PREFIX(retro_serialize_size)(void) { return 0; }
bool CORE_PREFIX(retro_serialize)(void *s, size_t len) { return true; }
bool CORE_PREFIX(retro_unserialize)(const void *s, size_t len) { return true; }
bool CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)
{
@ -654,39 +639,17 @@ bool CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)
return true;
}
bool CORE_PREFIX(retro_load_game_special)(unsigned type, const struct retro_game_info *info,
size_t num)
{
return false;
}
void CORE_PREFIX(retro_unload_game)(void)
{
free(filepath);
filepath = NULL;
}
unsigned CORE_PREFIX(retro_get_region)(void)
{
return RETRO_REGION_NTSC;
}
void *CORE_PREFIX(retro_get_memory_data)(unsigned id)
{
return NULL;
}
size_t CORE_PREFIX(retro_get_memory_size)(unsigned id)
{
return 0;
}
void CORE_PREFIX(retro_cheat_reset)(void)
{}
void CORE_PREFIX(retro_cheat_set)(unsigned index, bool enabled, const char *code)
{
(void)index;
(void)enabled;
(void)code;
}
bool CORE_PREFIX(retro_load_game_special)(unsigned type, const struct retro_game_info *info,
size_t num) { return false; }
unsigned CORE_PREFIX(retro_get_region)(void) { return RETRO_REGION_NTSC; }
void *CORE_PREFIX(retro_get_memory_data)(unsigned id) { return NULL; }
size_t CORE_PREFIX(retro_get_memory_size)(unsigned id) { return 0; }
void CORE_PREFIX(retro_cheat_reset)(void) { }
void CORE_PREFIX(retro_cheat_set)(unsigned a, bool b, const char *c) { }
void CORE_PREFIX(retro_reset)(void) { }

View File

@ -255,7 +255,7 @@ typedef struct
char *message;
} ITifJSONContext;
static bool ITifJSONObjectEndHandler(void* context)
static bool ITifJSONObjectEndHandler(void *context)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
@ -278,7 +278,7 @@ static bool ITifJSONObjectEndHandler(void* context)
return true;
}
static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
static bool ITifJSONObjectMemberHandler(void* context, const char *s, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
@ -288,39 +288,39 @@ static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_
if (len)
{
if (string_is_equal(pValue, "expected_button"))
pCtx->current_entry_uint_val = &pCtx->expected_button;
else if (string_is_equal(pValue, "message"))
pCtx->current_entry_str_val = &pCtx->message;
/* ignore unknown members */
if (string_is_equal(s, "expected_button"))
pCtx->current_entry_uint_val = &pCtx->expected_button;
else if (string_is_equal(s, "message"))
pCtx->current_entry_str_val = &pCtx->message;
}
return true;
}
static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t len)
static bool ITifJSONNumberHandler(void* context, const char *s, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */
if (pCtx->current_entry_uint_val && len && !string_is_empty(s))
*pCtx->current_entry_uint_val = string_to_unsigned(s);
pCtx->current_entry_uint_val = NULL;
return true;
}
static bool ITifJSONStringHandler(void* context, const char *pValue, size_t len)
static bool ITifJSONStringHandler(void* context, const char *s, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(s))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);
*pCtx->current_entry_str_val = strdup(pValue);
*pCtx->current_entry_str_val = strdup(s);
}
/* ignore unknown members */
@ -430,7 +430,6 @@ end:
static void sensors_init(void)
{
struct retro_sensor_interface sensor_interface = {0};
if (NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE, &sensor_interface)) {
@ -563,11 +562,7 @@ unsigned NETRETROPAD_CORE_PREFIX(retro_api_version)(void)
}
void NETRETROPAD_CORE_PREFIX(retro_set_controller_port_device)(
unsigned port, unsigned device)
{
(void)port;
(void)device;
}
unsigned port, unsigned device) { }
void NETRETROPAD_CORE_PREFIX(retro_get_system_info)(
struct retro_system_info *info)
@ -593,7 +588,7 @@ void NETRETROPAD_CORE_PREFIX(retro_get_system_av_info)(
}
static void NETRETROPAD_CORE_PREFIX(update_keyboard_cb)(bool down, unsigned keycode,
uint32_t character, uint16_t key_modifiers)
uint32_t character, uint16_t key_modifiers)
{
struct retro_message message;
char buf[NAME_MAX_LENGTH];
@ -601,7 +596,8 @@ static void NETRETROPAD_CORE_PREFIX(update_keyboard_cb)(bool down, unsigned keyc
if (keycode < RETROK_LAST)
{
keyboard_state[keycode] = down ? true : false;
if (down && ((keycode == RETROK_a && keyboard_state[RETROK_b]) || (keycode == RETROK_b && keyboard_state[RETROK_a])))
if (down && ((keycode == RETROK_a && keyboard_state[RETROK_b])
|| (keycode == RETROK_b && keyboard_state[RETROK_a])))
flip_screen();
/* Message for the keypresses not shown as actual keys, just placeholder blocks */
if ((keycode == 0) ||
@ -634,10 +630,9 @@ static unsigned get_pixel_coordinate(int val, unsigned dimension)
static unsigned set_pixel(unsigned x, unsigned y, unsigned color)
{
unsigned old_color;
uint16_t *pixel;
pixel = frame_buf + y * 320 + x;
uint16_t *pixel = frame_buf + y * 320 + x;
old_color = *pixel;
*pixel = color;
*pixel = color;
return old_color;
}
@ -849,7 +844,6 @@ static void netretropad_check_variables(void)
mouse_type = NETRETROPAD_LIGHTGUN_OLD;
else
mouse_type = 0;
}
void NETRETROPAD_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t cb)
@ -1040,9 +1034,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
* provided as a direct list. */
if (mouse_type == NETRETROPAD_MOUSE)
{
int offset;
offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
int offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
sensor_item_colors[80] = mouse.value[offset] ? 0xA000 : 0x0000;
offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE);
@ -1072,9 +1064,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
}
else if (mouse_type == NETRETROPAD_LIGHTGUN)
{
int offset;
offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_AUX_A);
int offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_AUX_A);
sensor_item_colors[70] = lightgun.value[offset] ? 0xA000 : 0x0000;
offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_AUX_B);
@ -1113,9 +1103,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
}
else if (mouse_type == NETRETROPAD_POINTER)
{
int offset;
offset = DESC_OFFSET(&pointer, 0, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
int offset = DESC_OFFSET(&pointer, 0, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
sensor_item_colors[104] = pointer.value[offset] ? 0xA000 : 0x0000;
offset = DESC_OFFSET(&pointer, 0, 1, RETRO_DEVICE_ID_POINTER_PRESSED);
@ -1417,52 +1405,23 @@ bool NETRETROPAD_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info
return true;
}
void NETRETROPAD_CORE_PREFIX(retro_unload_game)(void)
{}
void NETRETROPAD_CORE_PREFIX(retro_unload_game)(void) { }
unsigned NETRETROPAD_CORE_PREFIX(retro_get_region)(void) { return RETRO_REGION_NTSC; }
bool NETRETROPAD_CORE_PREFIX(retro_load_game_special)(unsigned type,
const struct retro_game_info *info, size_t num)
{
(void)type;
(void)info;
(void)num;
return false;
}
const struct retro_game_info *info, size_t num) { return false; }
size_t NETRETROPAD_CORE_PREFIX(retro_serialize_size)(void) { return 0; }
bool NETRETROPAD_CORE_PREFIX(retro_serialize)(void *data, size_t size)
{
(void)data;
(void)size;
return false;
}
bool NETRETROPAD_CORE_PREFIX(retro_serialize)(void *data,
size_t len) { return false; }
bool NETRETROPAD_CORE_PREFIX(retro_unserialize)(const void *data,
size_t size)
{
(void)data;
(void)size;
return false;
}
size_t len) { return false; }
size_t NETRETROPAD_CORE_PREFIX(retro_get_memory_size)(
unsigned id) { return 0; }
void NETRETROPAD_CORE_PREFIX(retro_cheat_reset)(void) { }
void NETRETROPAD_CORE_PREFIX(retro_cheat_set)(unsigned idx,
bool enabled, const char *code) { }
void *NETRETROPAD_CORE_PREFIX(retro_get_memory_data)(unsigned id)
{
(void)id;
return NULL;
}
size_t NETRETROPAD_CORE_PREFIX(retro_get_memory_size)(unsigned id) { return 0; }
void NETRETROPAD_CORE_PREFIX(retro_cheat_reset)(void)
{}
void NETRETROPAD_CORE_PREFIX(retro_cheat_set)(unsigned idx,
bool enabled, const char *code)
{
(void)idx;
(void)enabled;
(void)code;
}

View File

@ -21,7 +21,8 @@ struct MemBlock
static MemBlock* Create(u8* base, u32 size)
{
auto b = (MemBlock*)malloc(sizeof(MemBlock));
if (!b) return nullptr;
if (!b)
return nullptr;
b->prev = nullptr;
b->next = nullptr;
b->base = base;
@ -159,7 +160,7 @@ static bool linearInit(void)
return false;
}
void* linearMemAlign(size_t size, size_t alignment)
void* linearMemAlign(size_t len, size_t alignment)
{
int shift;
/* Enforce minimum alignment */
@ -181,7 +182,7 @@ void* linearMemAlign(size_t size, size_t alignment)
/* Allocate the chunk */
MemChunk chunk;
if (!sLinearPool.Allocate(chunk, size, shift))
if (!sLinearPool.Allocate(chunk, len, shift))
return nullptr;
auto node = newNode(chunk);
@ -198,35 +199,31 @@ void* linearMemAlign(size_t size, size_t alignment)
return chunk.addr;
}
void* linearAlloc(size_t size)
void* linearAlloc(size_t len)
{
#if 0
if(ctrConsole && ctrConsole->consoleInitialised)
if (ctrConsole && ctrConsole->consoleInitialised)
{
printf("linearAlloc : 0x%08X\n", size);
printf("linearAlloc : 0x%08X\n", len);
DEBUG_HOLD();
}
#endif
return linearMemAlign(size, 0x80);
return linearMemAlign(len, 0x80);
}
void* linearRealloc(void* mem, size_t size)
{
/* TODO */
return NULL;
}
void* linearRealloc(void* mem, size_t len) { return NULL; }
void linearFree(void* mem)
{
auto node = getNode(mem);
if (!node)
auto node = getNode(mem);
if (!node)
return;
/* Free the chunk */
sLinearPool.Deallocate(node->chunk);
/* Free the chunk */
sLinearPool.Deallocate(node->chunk);
/* Free the node */
delNode(node);
/* Free the node */
delNode(node);
}
u32 linearSpaceFree(void)
@ -236,7 +233,7 @@ u32 linearSpaceFree(void)
extern "C" u32 ctr_get_linear_free(void)
{
if(sLinearPool.last->base + sLinearPool.last->size != (u8*)__linear_heap + __linear_heap_size)
if (sLinearPool.last->base + sLinearPool.last->size != (u8*)__linear_heap + __linear_heap_size)
return 0;
return sLinearPool.last->size;
}
@ -248,16 +245,16 @@ extern "C" u32 ctr_get_linear_unused(void)
extern "C" void ctr_linear_free_pages(u32 pages)
{
if(sLinearPool.last->base + sLinearPool.last->size != (u8*)__linear_heap + __linear_heap_size)
u32 tmp, size;
if (sLinearPool.last->base + sLinearPool.last->size != (u8*)__linear_heap + __linear_heap_size)
return;
u32 size = pages << 12;
if(size > sLinearPool.last->size)
size = pages << 12;
if (size > sLinearPool.last->size)
return;
sLinearPool.last->size -= size;
__linear_heap_size -= size;
u32 tmp;
svcControlMemory(&tmp, __linear_heap + __linear_heap_size, 0x0, size,
MEMOP_FREE, (MemPerm)(MEMPERM_READ | MEMPERM_WRITE));

View File

@ -40,7 +40,7 @@ void ctr_free_pages(u32 pages)
u32 linear_free_pages;
u32 stack_free, stack_usage, stack_free_pages;
if(!pages)
if (!pages)
return;
linear_free_pages = ctr_get_linear_free() >> 12;
@ -54,31 +54,31 @@ void ctr_free_pages(u32 pages)
#endif
stack_free = ctr_get_stack_free();
stack_usage = __stacksize__ > stack_free
stack_usage = __stacksize__ > stack_free
? __stacksize__ - stack_free
: 0;
stack_free = stack_free > __stack_size_extra
? __stack_size_extra
stack_free = stack_free > __stack_size_extra
? __stack_size_extra
: stack_free;
stack_free_pages = stack_free >> 12;
if(linear_free_pages + (stack_free_pages - (stack_usage >> 12)) > pages)
if (linear_free_pages + (stack_free_pages - (stack_usage >> 12)) > pages)
{
stack_free_pages -= (stack_usage >> 12);
stack_free_pages = stack_free_pages > pages ? pages : stack_free_pages;
linear_free_pages = pages - stack_free_pages;
}
else if(linear_free_pages + stack_free_pages > pages)
else if (linear_free_pages + stack_free_pages > pages)
stack_free_pages = pages - linear_free_pages;
else
return;
if(linear_free_pages)
if (linear_free_pages)
ctr_linear_free_pages(linear_free_pages);
if(stack_free_pages)
if (stack_free_pages)
{
u32 tmp;
svcControlMemory(&tmp, __stack_bottom,

View File

@ -272,7 +272,7 @@ static void do_memchunkhax2(void)
svcControlMemory(&linear_buffer, 0, 0, 0x1000,
MEMOP_ALLOC_LINEAR, MEMPERM_READ | MEMPERM_WRITE);
mch2.alloc_size = ((((linear_size - (skip_pages << 12))
mch2.alloc_size = ((((linear_size - (skip_pages << 12))
+ 0x1000) >> 13) << 12);
mem_free = osGetMemRegionFree(MEMREGION_APPLICATION);
@ -303,14 +303,14 @@ static void do_memchunkhax2(void)
alloc_address_kaddr = osConvertVirtToPhys(
(void*)linear_address) + mch2.kernel_fcram_mapping_offset;
mch2.thread_page_kva = get_first_free_basemem_page(mch2.isNew3DS)
mch2.thread_page_kva = get_first_free_basemem_page(mch2.isNew3DS)
- 0x10000; /* skip down 16 pages */
((u32*)linear_buffer)[0] = 1;
((u32*)linear_buffer)[1] = mch2.thread_page_kva;
((u32*)linear_buffer)[2] = alloc_address_kaddr + (((mch2.alloc_size >> 12) - 3) << 13) + (skip_pages << 12);
dst_memchunk = linear_address
+ (((mch2.alloc_size >> 12) - 2) << 13)
dst_memchunk = linear_address
+ (((mch2.alloc_size >> 12) - 2) << 13)
+ (skip_pages << 12);
memcpy(flush_buffer, flush_buffer + 0x4000, 0x4000);
@ -319,7 +319,7 @@ static void do_memchunkhax2(void)
GSPGPU_FlushDataCache((void*)linear_buffer, 16);
memcpy(flush_buffer, flush_buffer + 0x4000, 0x4000);
/* can't clear gspEvents[GSPGPU_EVENT_PPF]),
/* can't clear gspEvents[GSPGPU_EVENT_PPF]),
* directly so execute a dummy copy
* and use gspWaitForEvent to clear it. */
@ -380,8 +380,8 @@ static void do_memchunkhax2(void)
thread_ACL[SVC_ACL_OFFSET(0x7B) >> 2] = SVC_ACL_MASK(0x7B);
GSPGPU_FlushDataCache((void*)thread_ACL, 16);
GSPGPU_InvalidateDataCache((void*)thread_ACL, 16);
mch2.threads[i].args.target_kaddr = get_thread_page()
+ THREAD_PAGE_ACL_OFFSET
mch2.threads[i].args.target_kaddr = get_thread_page()
+ THREAD_PAGE_ACL_OFFSET
+ SVC_ACL_OFFSET(0x7B);
mch2.threads[i].args.target_val = SVC_ACL_MASK(0x7B);
break;
@ -437,7 +437,7 @@ static void gspwn(u32 dst, u32 src, u32 size, u8* flush_buffer)
}
/* pseudo-code:
* if(val2)
* if (val2)
* {
* *(u32*)val1 = val2;
* *(u32*)(val2 + 8) = (val1 - 4);
@ -503,8 +503,8 @@ static void do_memchunkhax1(void)
u32 saved_vram_value = *(u32*)0x1F000008;
/* 0x1F000000 contains the enable bit for svc 0x7B */
memchunkhax1_write_pair(get_thread_page()
+ THREAD_PAGE_ACL_OFFSET
memchunkhax1_write_pair(get_thread_page()
+ THREAD_PAGE_ACL_OFFSET
+ SVC_ACL_OFFSET(0x7B), 0x1F000000);
write_kaddr(0x1F000008, saved_vram_value);
@ -540,10 +540,10 @@ Result svchax_init(bool patch_srv)
u32 luma_major, luma_minor;
if (kver > SYSTEM_VERSION(2, 50, 11) &&
(R_FAILED(get_luma_version(&luma_major, &luma_minor)
(R_FAILED(get_luma_version(&luma_major, &luma_minor)
|| luma_major < 8)))
return -1;
else if (kver > SYSTEM_VERSION(2, 46, 0)
else if (kver > SYSTEM_VERSION(2, 46, 0)
&& kver <= SYSTEM_VERSION(2, 50, 11))
do_memchunkhax2();
else if (kver <= SYSTEM_VERSION(2, 46, 0))
@ -557,7 +557,7 @@ Result svchax_init(bool patch_srv)
if (patch_srv && !__ctr_svchax_srv)
{
u32 PID_kaddr = read_kaddr(CURRENT_KPROCESS)
u32 PID_kaddr = read_kaddr(CURRENT_KPROCESS)
+ (isNew3DS ? 0xBC : (kver > SYSTEM_VERSION(2, 40, 0)) ? 0xB4 : 0xAC);
u32 old_PID = read_kaddr(PID_kaddr);
write_kaddr(PID_kaddr, 0);

View File

@ -187,12 +187,12 @@ Result APT_ReceiveDeliverArg_(void* param, size_t param_size,
staticbufs[2] = saved_threadstorage[2];
staticbufs[3] = saved_threadstorage[3];
if(R_FAILED(ret))
if (R_FAILED(ret))
return ret;
if(source_pid)
if (source_pid)
*source_pid = ((u64*)cmdbuf)[1];
if(received)
if (received)
*received = ((bool*)cmdbuf)[16];
return cmdbuf[1];
@ -212,7 +212,7 @@ void __system_initArgv(void)
u8 hmac[0x20];
bool received;
if(!__service_ptr
if (!__service_ptr
&& R_SUCCEEDED(APT_ReceiveDeliverArg_(&param, sizeof(param), hmac, sizeof(hmac), NULL, &received))
&& received
&& !memcmp(hmac, __argv_hmac, sizeof(__argv_hmac)))

View File

@ -235,7 +235,7 @@ typedef struct gfx_ctx_wayland_data
#ifdef HAVE_XKBCOMMON
/* FIXME: Move this into a header? */
int init_xkb(int fd, size_t size);
int init_xkb(int fd, size_t len);
int handle_xkb(int code, int value);
void handle_xkb_state_mask(uint32_t depressed,
uint32_t latched, uint32_t locked, uint32_t group);

View File

@ -32,10 +32,10 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
return;
/* if this is a CDROM-XA data source, the "CD001" tag will be 25 bytes into the sector */
if ( buffer[25] == 0x43
if ( buffer[25] == 0x43
&& buffer[26] == 0x44
&& buffer[27] == 0x30
&& buffer[28] == 0x30
&& buffer[27] == 0x30
&& buffer[28] == 0x30
&& buffer[29] == 0x31)
{
track->stream_sector_size = 2352;
@ -44,8 +44,8 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
/* otherwise it should be 17 bytes into the sector */
else if (buffer[17] == 0x43
&& buffer[18] == 0x44
&& buffer[19] == 0x30
&& buffer[20] == 0x30
&& buffer[19] == 0x30
&& buffer[20] == 0x30
&& buffer[21] == 0x31)
{
track->stream_sector_size = 2352;
@ -65,7 +65,7 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
&& buffer[ 7] == 0xFF
&& buffer[ 8] == 0xFF
&& buffer[ 9] == 0xFF
&& buffer[10] == 0xFF
&& buffer[10] == 0xFF
&& buffer[11] == 0)
{
/* if we didn't find a CD001 tag, this format may predate ISO-9660 */
@ -80,21 +80,21 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
static void cdfs_determine_sector_size_from_file_size(cdfs_track_t* track)
{
/* attempt to determine stream_sector_size from file size */
size_t size = intfstream_get_size(track->stream);
size_t _len = intfstream_get_size(track->stream);
if ((size % 2352) == 0)
if ((_len % 2352) == 0)
{
/* raw tracks use all 2352 bytes and have a 24 byte header */
track->stream_sector_size = 2352;
track->stream_sector_header_size = 24;
}
else if ((size % 2048) == 0)
else if ((_len % 2048) == 0)
{
/* cooked tracks eliminate all header/footer data */
track->stream_sector_size = 2048;
track->stream_sector_header_size = 0;
}
else if ((size % 2336) == 0)
else if ((_len % 2336) == 0)
{
/* MODE 2 format without 16-byte sync data */
track->stream_sector_size = 2336;
@ -172,7 +172,7 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
intfstream_read(file->track->stream, buffer, sizeof(buffer));
/* the directory_record starts at 156 bytes into the sector.
* the sector containing the root directory contents is a
* the sector containing the root directory contents is a
* 3 byte value that is 2 bytes into the directory_record. */
offset = 156 + 2;
sector = buffer[offset] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16);
@ -187,25 +187,25 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
while (tmp < buffer + sizeof(buffer))
{
/* The first byte of the record is the length of
/* The first byte of the record is the length of
* the record - if 0, we reached the end of the data */
if (!*tmp)
break;
/* filename is 33 bytes into the record and
/* filename is 33 bytes into the record and
* the format is "FILENAME;version" or "DIRECTORY" */
if ( (tmp[33 + path_length] == ';'
if ( (tmp[33 + path_length] == ';'
|| (tmp[33 + path_length] == '\0'))
&& strncasecmp((const char*)(tmp + 33), path, path_length) == 0)
{
/* the file size is in bytes 10-13 of the record */
file->size =
file->size =
(tmp[10])
| (tmp[11] << 8)
| (tmp[12] << 16)
| (tmp[11] << 8)
| (tmp[12] << 16)
| (tmp[13] << 24);
/* the file contents are in the sector identified
/* the file contents are in the sector identified
* in bytes 2-4 of the record */
sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16);
return sector;
@ -235,7 +235,7 @@ int cdfs_open_file(cdfs_file_t* file, cdfs_track_t* track, const char* path)
{
file->first_sector = 0;
file->size = (unsigned int)((intfstream_get_size(
file->track->stream) / file->track->stream_sector_size)
file->track->stream) / file->track->stream_sector_size)
* 2048);
return 1;
}
@ -319,8 +319,8 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
void cdfs_close_file(cdfs_file_t* file)
{
/* Not really anything to do here, just
* clear out the first_sector so
/* Not really anything to do here, just
* clear out the first_sector so
* read() won't do anything */
if (file)
file->first_sector = -1;
@ -461,7 +461,7 @@ static cdfs_track_t* cdfs_open_cue_track(
while (file_end > file && *file_end != ' ' && *file_end != '\t')
--file_end;
if ( file[0] == '"'
if ( file[0] == '"'
&& file_end[-1] == '"')
{
++file;

View File

@ -46,11 +46,11 @@ struct rwav_iterator
int step;
};
void rwav_init(rwav_iterator_t* iter, rwav_t* out, const void* buf, size_t size)
void rwav_init(rwav_iterator_t* iter, rwav_t* out, const void *s, size_t len)
{
iter->out = out;
iter->data = (const uint8_t*)buf;
iter->size = size;
iter->data = (const uint8_t*)s;
iter->size = len;
iter->step = ITER_BEGIN;
out->samples = NULL;
@ -159,7 +159,7 @@ enum rwav_state rwav_iterate(rwav_iterator_t *iter)
return RWAV_ITERATE_ERROR;
}
enum rwav_state rwav_load(rwav_t* out, const void* buf, size_t size)
enum rwav_state rwav_load(rwav_t* out, const void *s, size_t len)
{
enum rwav_state res;
rwav_iterator_t iter;
@ -171,7 +171,7 @@ enum rwav_state rwav_load(rwav_t* out, const void* buf, size_t size)
iter.j = 0;
iter.step = 0;
rwav_init(&iter, out, buf, size);
rwav_init(&iter, out, s, len);
do
{

View File

@ -5,17 +5,17 @@
static void nbio_write_test(void)
{
size_t size;
size_t _len;
bool looped = false;
void* ptr = NULL;
void *ptr = NULL;
struct nbio_t* write = nbio_open("test.bin", NBIO_WRITE);
if (!write)
puts("[ERROR]: nbio_open failed (1)");
nbio_resize(write, 1024*1024);
ptr = nbio_get_ptr(write, &size);
if (size != 1024*1024)
ptr = nbio_get_ptr(write, &_len);
if (_len != 1024*1024)
puts("[ERROR]: wrong size (1)");
memset(ptr, 0x42, 1024*1024);
@ -32,14 +32,14 @@ static void nbio_write_test(void)
static void nbio_read_test(void)
{
size_t size;
size_t _len;
bool looped = false;
struct nbio_t* read = nbio_open("test.bin", NBIO_READ);
void* ptr = nbio_get_ptr(read, &size);
void* ptr = nbio_get_ptr(read, &_len);
if (!read)
puts("[ERROR]: nbio_open failed (2)");
if (size != 1024*1024)
if (_len != 1024*1024)
puts("[ERROR]: wrong size (2)");
if (ptr)
puts("[SUCCESS]: Read pointer is available before iterating.");
@ -52,9 +52,9 @@ static void nbio_read_test(void)
if (!looped)
puts("[SUCCESS]: Read finished immediately.");
ptr = nbio_get_ptr(read, &size);
ptr = nbio_get_ptr(read, &_len);
if (size != 1024*1024)
if (_len != 1024*1024)
puts("[ERROR]: wrong size (3)");
if (*(char*)ptr != 0x42 || memcmp(ptr, (char*)ptr+1, 1024*1024-1))
puts("[ERROR]: wrong data");

View File

@ -55,14 +55,14 @@ void memoryRelease(void)
bucket_heap = NULL;
}
void* _memalign_r(struct _reent *r, size_t alignment, size_t size)
void* _memalign_r(struct _reent *r, size_t alignment, size_t len)
{
return MEMAllocFromExpHeapEx(MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2), size, alignment);
return MEMAllocFromExpHeapEx(MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2), len, alignment);
}
void* _malloc_r(struct _reent *r, size_t size)
void* _malloc_r(struct _reent *r, size_t len)
{
return _memalign_r(r, 4, size);
return _memalign_r(r, 4, len);
}
void _free_r(struct _reent *r, void *ptr)
@ -76,16 +76,16 @@ size_t _malloc_usable_size_r(struct _reent *r, void *ptr)
return MEMGetSizeForMBlockExpHeap(ptr);
}
void * _realloc_r(struct _reent *r, void *ptr, size_t size)
void * _realloc_r(struct _reent *r, void *ptr, size_t len)
{
void *realloc_ptr = NULL;
if (!ptr)
return _malloc_r(r, size);
return _malloc_r(r, len);
if (_malloc_usable_size_r(r, ptr) >= size)
if (_malloc_usable_size_r(r, ptr) >= len)
return ptr;
realloc_ptr = _malloc_r(r, size);
realloc_ptr = _malloc_r(r, len);
if(!realloc_ptr)
return NULL;
@ -96,24 +96,24 @@ void * _realloc_r(struct _reent *r, void *ptr, size_t size)
return realloc_ptr;
}
void* _calloc_r(struct _reent *r, size_t num, size_t size)
void* _calloc_r(struct _reent *r, size_t num, size_t len)
{
void *ptr = _malloc_r(r, num*size);
void *ptr = _malloc_r(r, num * len);
if(ptr)
memset(ptr, 0, num*size);
memset(ptr, 0, num * len);
return ptr;
}
void * _valloc_r(struct _reent *r, size_t size)
void * _valloc_r(struct _reent *r, size_t len)
{
return _memalign_r(r, 64, size);
return _memalign_r(r, 64, len);
}
/* some wrappers */
void * MEM2_alloc(unsigned int size, unsigned int align)
void *MEM2_alloc(unsigned int size, unsigned int align)
{
return MEMAllocFromExpHeapEx(MEMGetBaseHeapHandle(MEM_BASE_HEAP_MEM2), size, align);
}