This should fix linking on PSP.

svn-id: r40310
This commit is contained in:
Johannes Schickel 2009-05-04 16:52:13 +00:00
parent 6a8a9740a1
commit e63b778541
2 changed files with 57 additions and 71 deletions

View File

@ -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);

View File

@ -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);
};