diff --git a/binding-mri/audio-binding.cpp b/binding-mri/audio-binding.cpp index 541600b..1de027b 100644 --- a/binding-mri/audio-binding.cpp +++ b/binding-mri/audio-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index a08c0cd..f70b5db 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. @@ -21,6 +21,8 @@ #include "binding.h" #include "binding-util.h" +#include "ruby/internal/eval.h" +#include "ruby/internal/memory.h" #include "sharedstate.h" #include "eventthread.h" #include "filesystem.h" @@ -34,6 +36,7 @@ #include "sunshine.h" #include "modloader.h" +#include #include #include #include @@ -97,6 +100,7 @@ static void tp_cb(VALUE tpval, void *data) { } extern const char binding_mri_module_rpg1_rb[]; +extern const int binding_mri_module_rpg1_rb_len; static void mriBindingExecute(); static void mriBindingTerminate(); @@ -193,7 +197,13 @@ static void mriBindingInit(){ rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller"); _rb_define_module_function(rb_mKernel, "caller", _kernelCaller); - rb_eval_string(binding_mri_module_rpg1_rb); + char *script = (char*)SDL_malloc(binding_mri_module_rpg1_rb_len + 1); + SDL_memcpy(script, binding_mri_module_rpg1_rb, binding_mri_module_rpg1_rb_len); + script[binding_mri_module_rpg1_rb_len] = '\0'; + + rb_eval_string(script); + + SDL_free(script); VALUE mod = rb_define_module("MKXP"); _rb_define_module_function(mod, "data_directory", mkxpDataDirectory); @@ -466,6 +476,8 @@ static void runRMXPScripts(BacktraceData &btData){ VALUE scriptDecoded = rb_ary_entry(script, 3); VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded), RSTRING_LEN(scriptDecoded)); + rb_gc_register_address(&string); + VALUE fname; const char *scriptName = RSTRING_PTR(rb_ary_entry(script, 1)); char buf[512]; @@ -474,9 +486,15 @@ static void runRMXPScripts(BacktraceData &btData){ len = SDL_snprintf(buf, sizeof(buf), "%03ld:%s", i, scriptName); fname = newStringUTF8(buf, len); + rb_gc_register_address(&fname); + btData.scriptNames.insert(buf, scriptName); int state; evalString(string, fname, &state); + + rb_gc_unregister_address(&fname); + rb_gc_unregister_address(&string); + if (state) break; } diff --git a/binding-mri/binding-util.cpp b/binding-mri/binding-util.cpp index 568b897..8342602 100644 --- a/binding-mri/binding-util.cpp +++ b/binding-mri/binding-util.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/bitmap-binding.cpp b/binding-mri/bitmap-binding.cpp index 64a32ad..58ef3e1 100644 --- a/binding-mri/bitmap-binding.cpp +++ b/binding-mri/bitmap-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/etc-binding.cpp b/binding-mri/etc-binding.cpp index d5b1071..c33d8c2 100644 --- a/binding-mri/etc-binding.cpp +++ b/binding-mri/etc-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/filesystem-binding.cpp b/binding-mri/filesystem-binding.cpp index 98137ee..413e600 100644 --- a/binding-mri/filesystem-binding.cpp +++ b/binding-mri/filesystem-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/font-binding.cpp b/binding-mri/font-binding.cpp index 14f59c0..8ad5d23 100644 --- a/binding-mri/font-binding.cpp +++ b/binding-mri/font-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index e0fe38c..581bf97 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/input-binding.cpp b/binding-mri/input-binding.cpp index 0f5fd8f..27feece 100644 --- a/binding-mri/input-binding.cpp +++ b/binding-mri/input-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/plane-binding.cpp b/binding-mri/plane-binding.cpp index 52257ba..adc909e 100644 --- a/binding-mri/plane-binding.cpp +++ b/binding-mri/plane-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/sprite-binding.cpp b/binding-mri/sprite-binding.cpp index c8e8eef..7c53441 100644 --- a/binding-mri/sprite-binding.cpp +++ b/binding-mri/sprite-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/table-binding.cpp b/binding-mri/table-binding.cpp index ebbb0d9..1560515 100644 --- a/binding-mri/table-binding.cpp +++ b/binding-mri/table-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/tilemap-binding.cpp b/binding-mri/tilemap-binding.cpp index 3b44cd4..74b0d00 100644 --- a/binding-mri/tilemap-binding.cpp +++ b/binding-mri/tilemap-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/viewport-binding.cpp b/binding-mri/viewport-binding.cpp index 4d2aa84..d694d85 100644 --- a/binding-mri/viewport-binding.cpp +++ b/binding-mri/viewport-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/binding-mri/window-binding.cpp b/binding-mri/window-binding.cpp index e29c40f..a8cf07e 100644 --- a/binding-mri/window-binding.cpp +++ b/binding-mri/window-binding.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/changelogs/0.1.2.txt b/changelogs/0.1.2.txt index 4aaab65..f3d31fa 100644 --- a/changelogs/0.1.2.txt +++ b/changelogs/0.1.2.txt @@ -24,3 +24,4 @@ added icons and way to disable options in settings fixed segfault while to fast window size changing updated cg_blue picture Deleted useless hooks +fix crash on game exit diff --git a/src/alstream.cpp b/src/alstream.cpp index c7f82e3..5cc77de 100644 --- a/src/alstream.cpp +++ b/src/alstream.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2014 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/src/audio.cpp b/src/audio.cpp index 3d1e0ca..c2a6437 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/src/audiostream.cpp b/src/audiostream.cpp index f3da554..7c946fe 100644 --- a/src/audiostream.cpp +++ b/src/audiostream.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2014 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 614e657..4c335bf 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -5,7 +5,7 @@ ** ** Copyright (C) 2013 Jonas Kulla ** -** mkxp is SDL_free software: you can redistribute it and/or modify +** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. diff --git a/src/main.cpp b/src/main.cpp index fb1d64a..7444034 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -272,7 +272,6 @@ int main(int argc, char *argv[]){ if (dataDir) { int result = chdir(dataDir); (void)result; - SDL_free((void*)dataDir); // SDL_GetBasePath returns a heap pointer; SDL_free expects void* } #endif diff --git a/src/meow.cpp b/src/meow.cpp index 708fc02..58a3b62 100644 --- a/src/meow.cpp +++ b/src/meow.cpp @@ -133,7 +133,7 @@ void crash(Exception::Type t, const char *fmt, ...){ o << "Emscripten start address of the stack: " << emscripten_stack_get_base() << std::endl; o << "Emscripten end address of the stack: " << emscripten_stack_get_end() << std::endl; o << "Emscripten current stack pointer: " << emscripten_stack_get_current() << std::endl; - o << "Emscripten number of SDL_free bytes left on stack: " << emscripten_stack_get_free() << std::endl; + o << "Emscripten number of free bytes left on stack: " << emscripten_stack_get_free() << std::endl; #elif __PSP__ o << "PSPdev MIPS Stack Trace: " << int pspDebugGetStackTrace() << std::endl; #endif diff --git a/src/soundemitter.cpp b/src/soundemitter.cpp index 79856c6..811a2e0 100644 --- a/src/soundemitter.cpp +++ b/src/soundemitter.cpp @@ -119,7 +119,7 @@ void SoundEmitter::play(const std::string &filename, int volume, int pitch) { if (!buffer) return; - /* Try to find first SDL_free source */ + /* Try to find first free source */ size_t i; for (i = 0; i < srcCount; ++i) if (AL::Source::getState(alSrcs[srcPrio[i]]) != AL_PLAYING)