[Scummvm-cvs-logs] SF.net SVN: scummvm:[40433] scummvm/trunk/engines/sci/engine
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sun May 10 22:13:12 CEST 2009
Revision: 40433
http://scummvm.svn.sourceforge.net/scummvm/?rev=40433&view=rev
Author: fingolfin
Date: 2009-05-10 20:13:12 +0000 (Sun, 10 May 2009)
Log Message:
-----------
SCI: Replaced Cplain odeBlock array in class Script by a Common::Array<CodeBlock>
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/savegame.cpp
scummvm/trunk/engines/sci/engine/seg_manager.cpp
scummvm/trunk/engines/sci/engine/vm.h
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2009-05-10 19:18:19 UTC (rev 40432)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2009-05-10 20:13:12 UTC (rev 40433)
@@ -603,9 +603,7 @@
scr->locals_block = scr->locals_segment == 0 ? NULL : (LocalVariables *)(s->seg_manager->_heap[scr->locals_segment]);
scr->export_table = (uint16 *) find_unique_script_block(s, scr->buf, sci_obj_exports);
scr->synonyms = find_unique_script_block(s, scr->buf, sci_obj_synonyms);
- scr->code = NULL;
- scr->code_blocks_nr = 0;
- scr->code_blocks_allocated = 0;
+ scr->_codeBlocks.clear();
if (!self->isSci1_1)
scr->export_table += 3;
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-05-10 19:18:19 UTC (rev 40432)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-05-10 20:13:12 UTC (rev 40433)
@@ -192,9 +192,7 @@
scr.locals_offset = 0;
scr.locals_block = NULL;
- scr.code = NULL;
- scr.code_blocks_nr = 0;
- scr.code_blocks_allocated = 0;
+ scr._codeBlocks.clear();
scr.nr = script_nr;
scr.marked_as_deleted = 0;
@@ -373,8 +371,7 @@
delete obj_indices;
obj_indices = 0;
- free(code);
- code = 0;
+ _codeBlocks.clear();
}
// memory operations
@@ -541,14 +538,10 @@
void SegManager::scriptAddCodeBlock(reg_t location) {
Script *scr = getScript(location.segment, SEG_ID);
- if (++scr->code_blocks_nr > scr->code_blocks_allocated) {
- scr->code_blocks_allocated += DEFAULT_OBJECTS_INCREMENT;
- scr->code = (CodeBlock *)sci_realloc(scr->code, scr->code_blocks_allocated * sizeof(CodeBlock));
- }
-
- int index = scr->code_blocks_nr - 1;
- scr->code[index].pos = location;
- scr->code[index].size = READ_LE_UINT16(scr->buf + location.offset - 2);
+ CodeBlock cb;
+ cb.pos = location;
+ cb.size = READ_LE_UINT16(scr->buf + location.offset - 2);
+ scr->_codeBlocks.push_back(cb);
}
void SegManager::scriptRelocate(reg_t block) {
@@ -573,9 +566,9 @@
done = true;
}
- for (k = 0; !done && (int)k < scr->code_blocks_nr; k++) {
- if (pos >= scr->code[k].pos.offset &&
- pos < scr->code[k].pos.offset + scr->code[k].size)
+ for (k = 0; !done && k < scr->_codeBlocks.size(); k++) {
+ if (pos >= scr->_codeBlocks[k].pos.offset &&
+ pos < scr->_codeBlocks[k].pos.offset + scr->_codeBlocks[k].size)
done = true;
}
Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h 2009-05-10 19:18:19 UTC (rev 40432)
+++ scummvm/trunk/engines/sci/engine/vm.h 2009-05-10 20:13:12 UTC (rev 40433)
@@ -277,8 +277,6 @@
uint16 *base_method; /**< Pointer to the method selector area for this object */
uint16 *base_vars; /**< Pointer to the varselector area for this object */
reg_t *variables;
-
- Object() { memset(this, 0, sizeof(*this)); }
};
struct CodeBlock {
@@ -336,9 +334,7 @@
int locals_segment; /**< The local variable segment */
LocalVariables *locals_block;
- CodeBlock *code;
- int code_blocks_nr;
- int code_blocks_allocated;
+ Common::Array<CodeBlock> _codeBlocks;
int relocated;
int marked_as_deleted;
@@ -360,9 +356,6 @@
locals_segment = 0;
locals_block = NULL;
- code = NULL;
- code_blocks_nr = 0;
- code_blocks_allocated = 0;
relocated = 0;
marked_as_deleted = 0;
}
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