From 0bf380ff110897d2b5db2e22ef6efe1e9ba9888d Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 22 Nov 2016 16:16:58 +0100 Subject: fixed local Q-Register management on certain broken platforms * on MSVCRT/MinGW, space allocated with alloca()/g_newa() was apparently freed once the first exception was caught. This prevented the proper destruction of local Q-Reg tables and broke the Windows port. * Since all alternatives to alloca() like VLAs are not practical, the default Q-Register initialization has been moved out of the QRegisterTable constructor into QRegisterTable::insert_defaults(). * The remaining QRegisterTable initialization and destruction is very cheap, so we simply reserve an empty QRegisterTable for local registers on every Execute::macro() call. The default registers are only initialized when required, though. * All of this has to change anyway once we replace the C++ call-stack approach to macro calls with our own macro call frame memory management. --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index bc82093..ce00c0a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -384,6 +384,8 @@ main(int argc, char **argv) */ QRegisters::view.initialize(); + /* the default registers (A-Z and 0-9) */ + QRegisters::globals.insert_defaults(); /* search string and status register */ QRegisters::globals.insert("_"); /* replacement string register */ @@ -395,6 +397,8 @@ main(int argc, char **argv) /* environment defaults and registers */ initialize_environment(argv[0]); + /* the default registers (A-Z and 0-9) */ + local_qregs.insert_defaults(); QRegisters::locals = &local_qregs; ring.edit((const gchar *)NULL); -- cgit v1.2.3