diff options
-rw-r--r-- | engines/sci/engine/game.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index c9e8755c5d..e35386dbd4 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -433,9 +433,9 @@ int script_init_engine(EngineState *s, sci_version_t version) { SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR]; str->name = strdup("savedir"); str->max_size = MAX_SAVE_DIR_SIZE; - str->value = (reg_t*)sci_malloc(sizeof(reg_t)*MAX_SAVE_DIR_SIZE); - str->value->segment = s->string_frag_segment; // Set to empty string - str->value->offset = 0; + str->value = (reg_t *)calloc(MAX_SAVE_DIR_SIZE, sizeof(reg_t)); // FIXME -- sizeof(char) or sizeof(reg_t) ?? + str->value[0].segment = s->string_frag_segment; // Set to empty string + str->value[0].offset = 0; s->save_dir_copy = make_reg(s->sys_strings_segment, SYS_STRING_SAVEDIR); @@ -481,7 +481,7 @@ int script_init_engine(EngineState *s, sci_version_t version) { void script_set_gamestate_save_dir(EngineState *s, const char *path) { SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR]; - strncpy((char *)str->value, path, str->max_size); + strncpy((char *)str->value, path, str->max_size); // FIXME -- strncpy or internal_stringfrag_strncpy ? str->value[str->max_size - 1].segment = s->string_frag_segment; // Make sure to terminate str->value[str->max_size - 1].offset &= 0xff00; // Make sure to terminate } @@ -576,7 +576,7 @@ int game_init(EngineState *s) { SystemString *str = &s->sys_strings->strings[SYS_STRING_PARSER_BASE]; str->name = strdup("parser-base"); str->max_size = MAX_PARSER_BASE; - str->value = (reg_t*)sci_malloc(MAX_PARSER_BASE + 1); + str->value = (reg_t *)calloc(MAX_PARSER_BASE + 1, sizeof(char)); // FIXME -- sizeof(char) or sizeof(reg_t) ?? str->value[0].segment = s->string_frag_segment; // Set to empty string str->value[0].offset = 0; // Set to empty string diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 83cd125f11..a8f803c259 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -846,10 +846,10 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { // First, pad memory for (int i = 0; i < SYS_STRINGS_MAX; i++) { str = &retval->sys_strings->strings[i]; - char *data = (char *) str->value; + char *data = (char *)str->value; if (data) { - str->value = (reg_t *)sci_malloc(str->max_size + 1); - strcpy((char *)str->value, data); + str->value = (reg_t *)calloc(str->max_size+1, sizeof(char)); // FIXME -- sizeof(char) or sizeof(reg_t) ?? + strncpy((char *)str->value, data, str->max_size+1); // FIXME -- strncpy or internal_stringfrag_strncpy ? free(data); } } |