Skip to content

Commit

Permalink
more fixed size types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Nov 4, 2023
1 parent 6fb3ebc commit d403503
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/rapi/rc_api_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static char* g_imagehost = NULL;

/* --- rc_json --- */

static int rc_json_parse_object(rc_json_iterator_t* iterator, rc_json_field_t* fields, size_t field_count, unsigned* fields_seen);
static int rc_json_parse_object(rc_json_iterator_t* iterator, rc_json_field_t* fields, size_t field_count, uint32_t* fields_seen);
static int rc_json_parse_array(rc_json_iterator_t* iterator, rc_json_field_t* field);

static int rc_json_match_char(rc_json_iterator_t* iterator, char c)
Expand Down Expand Up @@ -182,7 +182,7 @@ static int rc_json_get_next_field(rc_json_iterator_t* iterator, rc_json_field_t*
return RC_OK;
}

static int rc_json_parse_object(rc_json_iterator_t* iterator, rc_json_field_t* fields, size_t field_count, unsigned* fields_seen) {
static int rc_json_parse_object(rc_json_iterator_t* iterator, rc_json_field_t* fields, size_t field_count, uint32_t* fields_seen) {
size_t i;
uint32_t num_fields = 0;
rc_json_field_t field;
Expand Down Expand Up @@ -437,14 +437,14 @@ int rc_json_get_required_unum_array(uint32_t** entries, uint32_t* num_entries, r
rc_json_iterator_t iterator;
rc_json_field_t array;
rc_json_field_t value;
unsigned* entry;
uint32_t* entry;

memset(&array, 0, sizeof(array));
if (!rc_json_get_required_array(num_entries, &array, response, field, field_name))
return RC_MISSING_VALUE;

if (*num_entries) {
*entries = (unsigned*)rc_buffer_alloc(&response->buffer, *num_entries * sizeof(unsigned));
*entries = (uint32_t*)rc_buffer_alloc(&response->buffer, *num_entries * sizeof(uint32_t));
if (!*entries)
return RC_OUT_OF_MEMORY;

Expand Down
2 changes: 1 addition & 1 deletion src/rc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void rc_buffer_destroy(rc_buffer_t* buffer)
{
rc_buffer_chunk_t* next = chunk->next;
#ifdef DEBUG_BUFFERS
total += (int)(chunk->end - chunk->data);
total += (int)(chunk->end - chunk->start);
wasted += (int)(chunk->end - chunk->write);
++count;
#endif
Expand Down
12 changes: 7 additions & 5 deletions src/rcheevos/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ void* rc_alloc_scratch(void* pointer, int32_t* offset, uint32_t size, uint32_t a
buffer = &scratch->buffer;
do {
const uint32_t aligned_buffer_offset = (buffer->offset + alignment - 1) & ~(alignment - 1);
const uint32_t remaining = sizeof(buffer->buffer) - aligned_buffer_offset;
if (aligned_buffer_offset < sizeof(buffer->buffer)) {
const uint32_t remaining = sizeof(buffer->buffer) - aligned_buffer_offset;

if (remaining >= size) {
/* claim the required space from an existing buffer */
return rc_alloc(buffer->buffer, &buffer->offset, size, alignment, NULL, -1);
if (remaining >= size) {
/* claim the required space from an existing buffer */
return rc_alloc(buffer->buffer, &buffer->offset, size, alignment, NULL, -1);
}
}

if (!buffer->next)
Expand Down Expand Up @@ -76,7 +78,7 @@ void* rc_alloc(void* pointer, int32_t* offset, uint32_t size, uint32_t alignment
void** scratch_object_pointer = (void**)((char*)&scratch->objs + scratch_object_pointer_offset);
ptr = *scratch_object_pointer;
if (!ptr) {
int used;
int32_t used;
ptr = *scratch_object_pointer = rc_alloc_scratch(NULL, &used, size, alignment, scratch, -1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rcheevos/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int rc_runtime_activate_achievement(rc_runtime_t* self, uint32_t id, const char*
rc_runtime_trigger_t* runtime_trigger;
rc_parse_state_t parse;
uint8_t md5[16];
int size;
uint32_t size;
uint32_t i;

if (memaddr == NULL)
Expand Down
6 changes: 3 additions & 3 deletions src/rhash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ static int rc_hash_dreamcast(char hash[33], const char* path)
}

static int rc_hash_find_playstation_executable(void* track_handle, const char* boot_key, const char* cdrom_prefix,
char exe_name[], uint32_t exe_name_size, unsigned* exe_size)
char exe_name[], uint32_t exe_name_size, uint32_t* exe_size)
{
uint8_t buffer[2048];
uint32_t size;
Expand All @@ -1626,7 +1626,7 @@ static int rc_hash_find_playstation_executable(void* track_handle, const char* b
if (!sector)
return 0;

size = (unsigned)rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer) - 1);
size = (uint32_t)rc_cd_read_sector(track_handle, sector, buffer, sizeof(buffer) - 1);
buffer[size] = '\0';

sector = 0;
Expand All @@ -1653,7 +1653,7 @@ static int rc_hash_find_playstation_executable(void* track_handle, const char* b
while (!isspace((unsigned char)*ptr) && *ptr != ';')
++ptr;

size = (unsigned)(ptr - start);
size = (uint32_t)(ptr - start);
if (size >= exe_name_size)
size = exe_name_size - 1;

Expand Down

0 comments on commit d403503

Please sign in to comment.