summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c12
-rw-r--r--io.c6
-rw-r--r--m68k_core.c5
3 files changed, 13 insertions, 10 deletions
diff --git a/config.c b/config.c
index b34aec0..16091b0 100644
--- a/config.c
+++ b/config.c
@@ -48,11 +48,11 @@ tern_node * parse_config_int(char **state, int started, int *line)
curline = strip_ws(curline);
int len = strlen(curline);
if (!len) {
- *line++;
+ *line = *line + 1;
continue;
}
if (curline[0] == '#') {
- *line++;
+ *line = *line + 1;
continue;
}
if (curline[0] == '}') {
@@ -67,7 +67,7 @@ tern_node * parse_config_int(char **state, int started, int *line)
if (*end == '{') {
*end = 0;
curline = strip_ws(curline);
- *line++;
+ *line = *line + 1;
head = tern_insert_node(head, curline, parse_config_int(state, 1, line));
} else {
char * val = strip_ws(split_keyval(curline));
@@ -77,7 +77,7 @@ tern_node * parse_config_int(char **state, int started, int *line)
} else {
fprintf(stderr, "Key %s is missing a value on line %d\n", key, *line);
}
- *line++;
+ *line = *line + 1;
}
}
return head;
@@ -100,10 +100,12 @@ tern_node * parse_config_file(char * config_path)
if (!config_size) {
goto config_empty;
}
- char * config_data = malloc(config_size);
+ char * config_data = malloc(config_size+1);
if (fread(config_data, 1, config_size, config_file) != config_size) {
goto config_read_fail;
}
+ config_data[config_size] = '\0';
+
ret = parse_config(config_data);
config_read_fail:
free(config_data);
diff --git a/io.c b/io.c
index 50d4df7..6199af0 100644
--- a/io.c
+++ b/io.c
@@ -340,7 +340,7 @@ void handle_joy_dpad(int joystick, int dpadnum, uint8_t value)
int parse_binding_target(char * target, tern_node * padbuttons, int * ui_out, int * padnum_out, int * padbutton_out)
{
int gpadslen = strlen("gamepads.");
- if (!memcmp(target, "gamepads.", gpadslen)) {
+ if (!strncmp(target, "gamepads.", gpadslen)) {
if (target[gpadslen] >= '1' && target[gpadslen] <= '8') {
int padnum = target[gpadslen] - '0';
int button = tern_find_int(padbuttons, target + gpadslen + 1, 0);
@@ -358,7 +358,7 @@ int parse_binding_target(char * target, tern_node * padbuttons, int * ui_out, in
} else {
fprintf(stderr, "Gamepad mapping string '%s' refers to an invalid gamepad number %c\n", target, target[gpadslen]);
}
- } else if(!memcmp(target, "ui.", strlen("ui."))) {
+ } else if(!strncmp(target, "ui.", strlen("ui."))) {
*padbutton_out = 0;
if (!strcmp(target + 3, "vdp_debug_mode")) {
*ui_out = UI_DEBUG_MODE_INC;
@@ -368,7 +368,7 @@ int parse_binding_target(char * target, tern_node * padbuttons, int * ui_out, in
*ui_out = UI_ENTER_DEBUGGER;
} else if(!strcmp(target + 3, "save_state")) {
*ui_out = UI_SAVE_STATE;
- } else if(!memcmp(target + 3, "set_speed.", strlen("set_speed."))) {
+ } else if(!strncmp(target + 3, "set_speed.", strlen("set_speed."))) {
*ui_out = UI_SET_SPEED;
*padbutton_out = atoi(target + 3 + strlen("set_speed."));
} else if(!strcmp(target + 3, "next_speed")) {
diff --git a/m68k_core.c b/m68k_core.c
index 5d88a2d..6b48080 100644
--- a/m68k_core.c
+++ b/m68k_core.c
@@ -1004,8 +1004,9 @@ void m68k_reset(m68k_context * context)
m68k_context * init_68k_context(m68k_options * opts)
{
- m68k_context * context = malloc(sizeof(m68k_context) + ram_size(&opts->gen) / (1 << opts->gen.ram_flags_shift) / 8);
- memset(context, 0, sizeof(m68k_context));
+ size_t ctx_size = sizeof(m68k_context) + ram_size(&opts->gen) / (1 << opts->gen.ram_flags_shift) / 8;
+ m68k_context * context = malloc(ctx_size);
+ memset(context, 0, ctx_size);
context->native_code_map = opts->gen.native_code_map;
context->options = opts;
context->int_cycle = CYCLE_NEVER;