aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorJohannes Schickel2009-05-04 16:52:13 +0000
committerJohannes Schickel2009-05-04 16:52:13 +0000
commite63b7785416bea132fd733599ef566b3a4442816 (patch)
treea306849233f82747b629632b0dfa4b44c682ef8e /engines/sci
parent6a8a9740a19cbb51a847467f4a6b75a4b04b16f8 (diff)
downloadscummvm-rg350-e63b7785416bea132fd733599ef566b3a4442816.tar.gz
scummvm-rg350-e63b7785416bea132fd733599ef566b3a4442816.tar.bz2
scummvm-rg350-e63b7785416bea132fd733599ef566b3a4442816.zip
This should fix linking on PSP.
svn-id: r40310
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/seg_manager.cpp65
-rw-r--r--engines/sci/engine/vm.h63
2 files changed, 57 insertions, 71 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 20470b8ebc..eae4bb5590 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -971,71 +971,6 @@ uint16 SegManager::validateExportFunc(int pubfunct, int seg) {
return offset;
}
-template<typename T, int INITIAL, int INCREMENT>
-Table<T, INITIAL, INCREMENT>::Table() {
- entries_nr = 0;
- max_entry = 0;
- entries_used = 0;
- first_free = HEAPENTRY_INVALID;
- table = NULL;
-}
-
-template<typename T, int INITIAL, int INCREMENT>
-Table<T, INITIAL, INCREMENT>::~Table() {
- // FIXME: Shouldn't we make sure that all table entries are disposed
- // of properly?
- free(table);
- table = NULL;
- entries_nr = max_entry = 0;
-}
-
-template<typename T, int INITIAL, int INCREMENT>
-void Table<T, INITIAL, INCREMENT>::initTable() {
- entries_nr = INITIAL;
- max_entry = 0;
- entries_used = 0;
- first_free = HEAPENTRY_INVALID;
- table = (Entry *)calloc(INITIAL, sizeof(Entry));
-}
-
-template<typename T, int INITIAL, int INCREMENT>
-int Table<T, INITIAL, INCREMENT>::allocEntry() {
- entries_used++;
- if (first_free != HEAPENTRY_INVALID) {
- int oldff = first_free;
- first_free = table[oldff].next_free;
-
- table[oldff].next_free = oldff;
- return oldff;
- } else {
- if (max_entry == entries_nr) {
- entries_nr += INCREMENT;
-
- table = (Entry *)sci_realloc(table, sizeof(Entry) * entries_nr);
- memset(&table[entries_nr-INCREMENT], 0, INCREMENT * sizeof(Entry));
- }
- table[max_entry].next_free = max_entry; /* Tag as 'valid' */
- return max_entry++;
- }
-}
-
-template<typename T, int INITIAL, int INCREMENT>
-void Table<T, INITIAL, INCREMENT>::freeEntry(int idx) {
- if (idx < 0 || idx >= max_entry) {
- error("Table::freeEntry: Attempt to release invalid table index %d", idx);
- }
-
- table[idx].next_free = first_free;
- first_free = idx;
- entries_used--;
-}
-
-template<typename T, int INITIAL, int INCREMENT>
-bool Table<T, INITIAL, INCREMENT>::isValidEntry(int idx) {
- return idx >= 0 && idx < max_entry && table[idx].next_free == idx;
-}
-
-
void SegManager::free_hunk_entry(reg_t addr) {
HunkTable *ht = (HunkTable *)GET_SEGMENT(*this, addr.segment, MEM_OBJ_HUNK);
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 49422f23d5..cb08f10cb2 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -32,6 +32,8 @@
#include "sci/scicore/versions.h" // for sci_version_t
#include "sci/engine/vm_types.h" // for reg_t
+#include "common/util.h"
+
namespace Sci {
enum MemObjectType {
@@ -408,13 +410,62 @@ struct Table : public MemObject {
Entry *table;
public:
- Table();
- ~Table();
+ Table() {
+ entries_nr = 0;
+ max_entry = 0;
+ entries_used = 0;
+ first_free = HEAPENTRY_INVALID;
+ table = NULL;
+ }
- void initTable();
- int allocEntry();
- bool isValidEntry(int idx);
- virtual void freeEntry(int idx);
+ ~Table() {
+ // FIXME: Shouldn't we make sure that all table entries are disposed
+ // of properly?
+ free(table);
+ table = NULL;
+ entries_nr = max_entry = 0;
+ }
+
+ void initTable() {
+ entries_nr = INITIAL;
+ max_entry = 0;
+ entries_used = 0;
+ first_free = HEAPENTRY_INVALID;
+ table = (Entry *)calloc(INITIAL, sizeof(Entry));
+ }
+
+ int allocEntry() {
+ entries_used++;
+ if (first_free != HEAPENTRY_INVALID) {
+ int oldff = first_free;
+ first_free = table[oldff].next_free;
+
+ table[oldff].next_free = oldff;
+ return oldff;
+ } else {
+ if (max_entry == entries_nr) {
+ entries_nr += INCREMENT;
+
+ table = (Entry *)sci_realloc(table, sizeof(Entry) * entries_nr);
+ memset(&table[entries_nr-INCREMENT], 0, INCREMENT * sizeof(Entry));
+ }
+ table[max_entry].next_free = max_entry; /* Tag as 'valid' */
+ return max_entry++;
+ }
+ }
+
+ bool isValidEntry(int idx) {
+ return idx >= 0 && idx < max_entry && table[idx].next_free == idx;
+ }
+
+ virtual void freeEntry(int idx) {
+ if (idx < 0 || idx >= max_entry)
+ ::error("Table::freeEntry: Attempt to release invalid table index %d", idx);
+
+ table[idx].next_free = first_free;
+ first_free = idx;
+ entries_used--;
+ }
// virtual void saveLoadWithSerializer(Common::Serializer &ser);
};