From 3c23ba7d7338bf8566eb581eb7567340951e6481 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 17 Mar 2009 16:07:58 +0000 Subject: SCI: Got rid of various SegManager::free_* methods svn-id: r39484 --- engines/sci/engine/seg_manager.cpp | 37 +++++++++++++++++-------------------- engines/sci/engine/seg_manager.h | 13 ------------- 2 files changed, 17 insertions(+), 33 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 8d58b94fc4..2b9a1bae8a 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -1259,7 +1259,14 @@ uint16 SegManager::validateExportFunc(int pubfunct, int seg) { } void SegManager::free_hunk_entry(reg_t addr) { - free_Hunk(addr); + MemObject *mobj = GET_SEGMENT(*this, addr.segment, MEM_OBJ_HUNK); + + if (!mobj) { + sciprintf("Attempt to free Hunk from address "PREG": Invalid segment type\n", PRINT_REG(addr)); + return; + } + + Sci::free_Hunk_entry(&(mobj->data.hunks), addr.offset); } Hunk *SegManager::alloc_hunk_entry(const char *hunk_type, int size, reg_t *reg) { @@ -1290,7 +1297,7 @@ DEFINE_HEAPENTRY(Node, 32, 16) DEFINE_HEAPENTRY_WITH_CLEANUP(Clone, 16, 4, _clone_cleanup) DEFINE_HEAPENTRY_WITH_CLEANUP(Hunk, 4, 4, _hunk_cleanup) -#define DEFINE_ALLOC_DEALLOC(TYPE, SEGTYPE, PLURAL) \ +#define DEFINE_ALLOC(TYPE, SEGTYPE, PLURAL) \ TYPE *SegManager::alloc_##TYPE(reg_t *addr) { \ MemObject *mobj; \ TYPE##Table *table; \ @@ -1307,23 +1314,13 @@ TYPE *SegManager::alloc_##TYPE(reg_t *addr) { \ \ *addr = make_reg(TYPE##s_seg_id, offset); \ return &(mobj->data.PLURAL.table[offset].entry); \ -} \ - \ -void SegManager::free_##TYPE(reg_t addr) { \ - MemObject *mobj = GET_SEGMENT(*this, addr.segment, SEGTYPE); \ - \ - if (!mobj) { \ - sciprintf("Attempt to free " #TYPE " from address "PREG": Invalid segment type\n", PRINT_REG(addr)); \ - return; \ - } \ - \ - Sci::free_##TYPE##_entry(&(mobj->data.PLURAL), addr.offset); \ } -DEFINE_ALLOC_DEALLOC(Clone, MEM_OBJ_CLONES, clones) -DEFINE_ALLOC_DEALLOC(List, MEM_OBJ_LISTS, lists) -DEFINE_ALLOC_DEALLOC(Node, MEM_OBJ_NODES, nodes) -DEFINE_ALLOC_DEALLOC(Hunk, MEM_OBJ_HUNK, hunks) +DEFINE_ALLOC(Clone, MEM_OBJ_CLONES, clones) +DEFINE_ALLOC(List, MEM_OBJ_LISTS, lists) +DEFINE_ALLOC(Node, MEM_OBJ_NODES, nodes) +DEFINE_ALLOC(Hunk, MEM_OBJ_HUNK, hunks) + byte *SegManager::dereference(reg_t pointer, int *size) { MemObject *mobj; @@ -1600,7 +1597,7 @@ void SegInterfaceClones::freeAtAddress(reg_t addr) { */ free(victim_obj->variables); victim_obj->variables = NULL; - _segmgr->free_Clone(addr); + Sci::free_Clone_entry(&(_mobj->data.clones), addr.offset); } @@ -1689,7 +1686,7 @@ public: }; void SegInterfaceLists::freeAtAddress(reg_t sub_addr) { - _segmgr->free_List(sub_addr); + Sci::free_List_entry(&(_mobj->data.lists), sub_addr.offset); } void SegInterfaceLists::listAllDeallocatable(void *param, void (*note)(void*param, reg_t addr)) { @@ -1723,7 +1720,7 @@ public: }; void SegInterfaceNodes::freeAtAddress(reg_t sub_addr) { - _segmgr->free_Node(sub_addr); + Sci::free_Node_entry(&(_mobj->data.nodes), sub_addr.offset); } void SegInterfaceNodes::listAllDeallocatable(void *param, void (*note)(void*param, reg_t addr)) { diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index ba7fcb5795..78cb8bd005 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -255,10 +255,6 @@ public: // (reg_t) *addr: The offset of the freshly allocated clone Clone *alloc_Clone(reg_t *addr); - // Deallocates a Clone - // Parameters: (reg_t) addr: Offset of the Clone scheduled for termination - void free_Clone(reg_t addr); - // 3. Objects (static, from Scripts, and dynmic, from Clones) @@ -319,19 +315,11 @@ public: // (reg_t) *addr: The offset of the freshly allocated list List *alloc_List(reg_t *addr); - // Deallocates a list - // Parameters: (reg_t) addr: Offset of the list scheduled for termination - void free_List(reg_t addr); - // Allocate a fresh node // Returns : (node_t*): Reference to the memory allocated for the node // (reg_t) *addr: The offset of the freshly allocated node Node *alloc_Node(reg_t *addr); - // Deallocates a list node - // Parameters: (reg_t) addr: Offset of the node scheduled for termination - void free_Node(reg_t addr); - // 8. Hunk Memory @@ -429,7 +417,6 @@ private: int deallocate(int seg, bool recursive); Hunk *alloc_Hunk(reg_t *); - void free_Hunk(reg_t addr); int relocateLocal(Script *scr, SegmentId segment, int location); int relocateBlock(reg_t *block, int block_location, int block_items, SegmentId segment, int location); -- cgit v1.2.3