[Scummvm-cvs-logs] SF.net SVN: scummvm:[47989] scummvm/trunk/engines/sci/engine
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Mon Feb 8 16:51:00 CET 2010
Revision: 47989
http://scummvm.svn.sourceforge.net/scummvm/?rev=47989&view=rev
Author: mthreepwood
Date: 2010-02-08 15:51:00 +0000 (Mon, 08 Feb 2010)
Log Message:
-----------
Search through arrays for outgoing references to fix possible garbage collector problems; minor cleanup.
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kernel32.cpp
scummvm/trunk/engines/sci/engine/segment.cpp
scummvm/trunk/engines/sci/engine/segment.h
Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp 2010-02-08 11:44:29 UTC (rev 47988)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp 2010-02-08 15:51:00 UTC (rev 47989)
@@ -439,8 +439,7 @@
return argv[1]; // We also have to return the handle
}
case 4: // Free
- if (!argv[1].isNull())
- s->_segMan->freeArray(argv[1]);
+ // Freeing of arrays is handled by the garbage collector
return s->r_acc;
case 5: { // Fill
SciArray<reg_t> *array = s->_segMan->lookupArray(argv[1]);
@@ -542,8 +541,7 @@
return argv[1]; // We also have to return the handle
}
case 4: // Free
- if (!argv[1].isNull())
- s->_segMan->freeString(argv[1]);
+ // Freeing of strings is handled by the garbage collector
return s->r_acc;
case 5: { // Fill
SciString *string = s->_segMan->lookupString(argv[1]);
Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp 2010-02-08 11:44:29 UTC (rev 47988)
+++ scummvm/trunk/engines/sci/engine/segment.cpp 2010-02-08 15:51:00 UTC (rev 47989)
@@ -695,6 +695,26 @@
return ret;
}
+void ArrayTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
+ _table[sub_addr.offset].destroy();
+ freeEntry(sub_addr.offset);
+}
+
+void ArrayTable::listAllOutgoingReferences(reg_t addr, void *param, NoteCallback note) {
+ if (!isValidEntry(addr.offset)) {
+ warning("Invalid array referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
+ return;
+ }
+
+ SciArray<reg_t> *array = &(_table[addr.offset]);
+
+ for (uint32 i = 0; i < array->getSize(); i++) {
+ reg_t value = array->getValue(i);
+ if (value.segment != 0)
+ note(param, value);
+ }
+}
+
Common::String SciString::toString() {
if (_type != 3)
error("SciString::toString(): Array is not a string");
@@ -725,6 +745,11 @@
return ret;
}
+void StringTable::freeAtAddress(SegManager *segMan, reg_t sub_addr) {
+ _table[sub_addr.offset].destroy();
+ freeEntry(sub_addr.offset);
+}
+
#endif
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h 2010-02-08 11:44:29 UTC (rev 47988)
+++ scummvm/trunk/engines/sci/engine/segment.h 2010-02-08 15:51:00 UTC (rev 47989)
@@ -796,7 +796,7 @@
SciString() : SciArray<char>() { setType(3); }
// We overload destroy to ensure the string type is 3 after destroying
- void destroy() { _type = 3; }
+ void destroy() { SciArray<char>::destroy(); _type = 3; }
Common::String toString();
void fromString(Common::String string);
@@ -805,6 +805,9 @@
struct ArrayTable : public Table<SciArray<reg_t> > {
ArrayTable() : Table<SciArray<reg_t> >(SEG_TYPE_ARRAY) {}
+ virtual void freeAtAddress(SegManager *segMan, reg_t sub_addr);
+ virtual void listAllOutgoingReferences(reg_t object, void *param, NoteCallback note);
+
void saveLoadWithSerializer(Common::Serializer &ser);
SegmentRef dereference(reg_t pointer);
};
@@ -812,6 +815,8 @@
struct StringTable : public Table<SciString> {
StringTable() : Table<SciString>(SEG_TYPE_STRING) {}
+ virtual void freeAtAddress(SegManager *segMan, reg_t sub_addr);
+
void saveLoadWithSerializer(Common::Serializer &ser);
SegmentRef dereference(reg_t pointer);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list