aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/glulxe/exec.cpp2
-rw-r--r--engines/glk/glulxe/glkop.cpp4
-rw-r--r--engines/glk/streams.cpp10
-rw-r--r--engines/glk/streams.h6
4 files changed, 21 insertions, 1 deletions
diff --git a/engines/glk/glulxe/exec.cpp b/engines/glk/glulxe/exec.cpp
index 55cd918ebb..01faad888f 100644
--- a/engines/glk/glulxe/exec.cpp
+++ b/engines/glk/glulxe/exec.cpp
@@ -39,7 +39,7 @@ void Glulxe::execute_loop() {
gfloat32 valf, valf1, valf2;
#endif /* FLOAT_SUPPORT */
- while (!done_executing) {
+ while (!done_executing && !g_vm->shouldQuit()) {
profile_tick();
debugger_tick();
diff --git a/engines/glk/glulxe/glkop.cpp b/engines/glk/glulxe/glkop.cpp
index 68e60c7bec..635d90bb7b 100644
--- a/engines/glk/glulxe/glkop.cpp
+++ b/engines/glk/glulxe/glkop.cpp
@@ -1165,6 +1165,10 @@ void Glulxe::glulxe_retained_unregister(void *array, uint len, const char *type
uint ix, addr2, val;
uint elemsize = 0;
+ // TODO: See if original GLULXE has code I'm overlooking to cleanly close everything before freeing memmap
+ if (!memmap)
+ return;
+
if (typecode[4] == 'C')
elemsize = 1;
else if (typecode[4] == 'I')
diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index b124e30ec9..907cde4d66 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -318,6 +318,16 @@ MemoryStream::MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode
else
_bufEnd = (byte *)buf + buflen;
_bufEof = mode == filemode_Write ? _buf : _bufEnd;
+
+ if (g_vm->gli_register_arr)
+ _arrayRock = (*g_vm->gli_register_arr)(buf, buflen, unicode ? "&+#!Iu" : "&+#!Cn");
+}
+
+MemoryStream::~MemoryStream() {
+ if (g_vm->gli_unregister_arr) {
+ const char *typedesc = _unicode ? "&+#!Iu" : "&+#!Cn";
+ (*g_vm->gli_unregister_arr)(_buf, _bufLen, typedesc, _arrayRock);
+ }
}
void MemoryStream::putChar(unsigned char ch) {
diff --git a/engines/glk/streams.h b/engines/glk/streams.h
index a34ba6f0a4..f899936ef3 100644
--- a/engines/glk/streams.h
+++ b/engines/glk/streams.h
@@ -381,6 +381,7 @@ private:
void *_bufEnd;
void *_bufEof;
size_t _bufLen; ///< # of bytes for latin1, # of 4-byte words for unicode
+ gidispatch_rock_t _arrayRock;
public:
/**
* Constructor
@@ -388,6 +389,11 @@ public:
MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode mode, uint rock = 0, bool unicode = true);
/**
+ * Destructor
+ */
+ virtual ~MemoryStream();
+
+ /**
* Write a character
*/
virtual void putChar(unsigned char ch) override;