[Scummvm-git-logs] scummvm master -> df3e9e3b058757462d95af5dfbf6b6e7e0c56ccd

mduggan mgithub at guarana.org
Sat May 9 05:55:52 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
df3e9e3b05 ULTIMA8: Remove custom memory manager from engine (#2227)


Commit: df3e9e3b058757462d95af5dfbf6b6e7e0c56ccd
    https://github.com/scummvm/scummvm/commit/df3e9e3b058757462d95af5dfbf6b6e7e0c56ccd
Author: Matthew Jimenez (48367439+OMGPizzaGuy at users.noreply.github.com)
Date: 2020-05-09T14:55:49+09:00

Commit Message:
ULTIMA8: Remove custom memory manager from engine (#2227)

* ULTIMA8: Remove custom memory manager from engine
* ULTIMA8: Remove pent_include.cpp as it is empty

Changed paths:
  R engines/ultima/ultima8/kernel/allocator.cpp
  R engines/ultima/ultima8/kernel/allocator.h
  R engines/ultima/ultima8/kernel/memory_manager.cpp
  R engines/ultima/ultima8/kernel/memory_manager.h
  R engines/ultima/ultima8/kernel/pool.cpp
  R engines/ultima/ultima8/kernel/pool.h
  R engines/ultima/ultima8/kernel/segmented_allocator.cpp
  R engines/ultima/ultima8/kernel/segmented_allocator.h
  R engines/ultima/ultima8/kernel/segmented_pool.cpp
  R engines/ultima/ultima8/kernel/segmented_pool.h
  R engines/ultima/ultima8/misc/pent_include.cpp
    engines/ultima/module.mk
    engines/ultima/ultima8/graphics/shape.cpp
    engines/ultima/ultima8/graphics/shape.h
    engines/ultima/ultima8/kernel/object.cpp
    engines/ultima/ultima8/kernel/object.h
    engines/ultima/ultima8/kernel/process.cpp
    engines/ultima/ultima8/kernel/process.h
    engines/ultima/ultima8/misc/debugger.cpp
    engines/ultima/ultima8/misc/debugger.h
    engines/ultima/ultima8/misc/pent_include.h
    engines/ultima/ultima8/ultima8.cpp
    engines/ultima/ultima8/ultima8.h
    engines/ultima/ultima8/world/world.cpp


diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index f4a0fbcab9..2f4f49fe1a 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -488,25 +488,19 @@ MODULE_OBJS := \
 	ultima8/gumps/widgets/edit_widget.o \
 	ultima8/gumps/widgets/sliding_widget.o \
 	ultima8/gumps/widgets/text_widget.o \
-	ultima8/kernel/allocator.o \
 	ultima8/kernel/core_app.o \
 	ultima8/kernel/delay_process.o \
 	ultima8/kernel/hid_keys.o \
 	ultima8/kernel/kernel.o \
-	ultima8/kernel/memory_manager.o \
 	ultima8/kernel/mouse.o \
 	ultima8/kernel/object.o \
 	ultima8/kernel/object_manager.o \
-	ultima8/kernel/pool.o \
 	ultima8/kernel/process.o \
-	ultima8/kernel/segmented_allocator.o \
-	ultima8/kernel/segmented_pool.o \
 	ultima8/misc/args.o \
 	ultima8/misc/debugger.o \
 	ultima8/misc/encoding.o \
 	ultima8/misc/id_man.o \
 	ultima8/misc/istring.o \
-	ultima8/misc/pent_include.o \
 	ultima8/misc/util.o \
 	ultima8/usecode/bit_set.o \
 	ultima8/usecode/uc_list.o \
diff --git a/engines/ultima/ultima8/graphics/shape.cpp b/engines/ultima/ultima8/graphics/shape.cpp
index b3bc6cfda5..2f33fa3d6a 100644
--- a/engines/ultima/ultima8/graphics/shape.cpp
+++ b/engines/ultima/ultima8/graphics/shape.cpp
@@ -37,8 +37,6 @@ namespace Ultima8 {
 
 DEFINE_RUNTIME_CLASSTYPE_CODE_BASE_CLASS(Shape)
 
-DEFINE_CUSTOM_MEMORY_ALLOCATION(Shape)
-
 Shape::Shape(const uint8 *data, uint32 size, const ConvertShapeFormat *format,
              const uint16 id, const uint32 shape)
 		: _flexId(id), _shapeNum(shape), _palette(nullptr) {
diff --git a/engines/ultima/ultima8/graphics/shape.h b/engines/ultima/ultima8/graphics/shape.h
index 7b99d6c666..a5e8667be4 100644
--- a/engines/ultima/ultima8/graphics/shape.h
+++ b/engines/ultima/ultima8/graphics/shape.h
@@ -71,8 +71,6 @@ public:
 
 	ENABLE_RUNTIME_CLASSTYPE_BASE()
 
-	ENABLE_CUSTOM_MEMORY_ALLOCATION()
-
 private:
 	void loadFrames(const uint8 *data, uint32 size, const ConvertShapeFormat *format);
 
diff --git a/engines/ultima/ultima8/kernel/allocator.cpp b/engines/ultima/ultima8/kernel/allocator.cpp
deleted file mode 100644
index 357cd603ae..0000000000
--- a/engines/ultima/ultima8/kernel/allocator.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/kernel/allocator.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-// p_dynamic_cast stuff
-DEFINE_RUNTIME_CLASSTYPE_CODE_BASE_CLASS(Allocator)
-
-Allocator::Allocator() {
-}
-
-Allocator::~Allocator() {
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/kernel/allocator.h b/engines/ultima/ultima8/kernel/allocator.h
deleted file mode 100644
index 87197678df..0000000000
--- a/engines/ultima/ultima8/kernel/allocator.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_KERNEL_ALLOCATOR_H
-#define ULTIMA8_KERNEL_ALLOCATOR_H
-
-#include "ultima/ultima8/kernel/pool.h"
-#include "ultima/ultima8/misc/p_dynamic_cast.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class Allocator {
-public:
-	Allocator();
-	virtual ~Allocator();
-
-	ENABLE_RUNTIME_CLASSTYPE_BASE()
-
-	virtual void *allocate(size_t size) = 0;
-
-	virtual Pool *findPool(void *ptr) = 0;
-
-	// Frees unneeded system resources
-	virtual void freeResources() = 0;
-
-	virtual size_t getCapacity() = 0;
-
-	virtual void printInfo() const = 0;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/kernel/memory_manager.cpp b/engines/ultima/ultima8/kernel/memory_manager.cpp
deleted file mode 100644
index 0c4a2682a6..0000000000
--- a/engines/ultima/ultima8/kernel/memory_manager.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/kernel/memory_manager.h"
-#include "ultima/ultima8/kernel/segmented_allocator.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-MemoryManager *MemoryManager::_memoryManager;
-
-MemoryManager::MemoryManager() {
-	_memoryManager = this;
-
-	//!!! CONSTANT !!!!
-	_allocatorCount = 2;
-	// Tune these with averages from MemoryManager::MemInfo when needed
-	_allocators[0] = new SegmentedAllocator(192, 8500);
-	_allocators[1] = new SegmentedAllocator(4224, 25);
-
-	setAllocationFunctions(MemoryManager::allocate,
-	                                  MemoryManager::deallocate);
-}
-
-MemoryManager::~MemoryManager() {
-	_memoryManager = nullptr;
-
-	setAllocationFunctions(malloc, free);
-	delete _allocators[0];
-	delete _allocators[1];
-}
-
-void *MemoryManager::_allocate(size_t size) {
-	int i;
-	// get the memory from the first allocator that can hold "size"
-	for (i = 0; i < _allocatorCount; ++i) {
-		if (_allocators[i]->getCapacity() >= size) {
-			return _allocators[i]->allocate(size);
-		}
-	}
-
-	// else
-	void *ptr = malloc(size);
-#ifdef DEBUG
-	debugN"MemoryManager::allocate - Allocated %d bytes to 0x%X\n", size, ptr);
-#endif
-
-	return ptr;
-}
-
-void MemoryManager::_deallocate(void *ptr) {
-	Pool *p;
-	int i;
-	for (i = 0; i < _allocatorCount; ++i) {
-		p = _allocators[i]->findPool(ptr);
-		if (p) {
-			p->deallocate(ptr);
-			return;
-		}
-	}
-
-#ifdef DEBUG
-	debugN"MemoryManager::deallocate - deallocating memory at 0x%X\n", ptr);
-#endif
-	// Pray!
-	free(ptr);
-}
-
-void MemoryManager::freeResources() {
-	int i;
-	for (i = 0; i < _allocatorCount; ++i) {
-		_allocators[i]->freeResources();
-	}
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/kernel/memory_manager.h b/engines/ultima/ultima8/kernel/memory_manager.h
deleted file mode 100644
index 5da99f26e2..0000000000
--- a/engines/ultima/ultima8/kernel/memory_manager.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_KERNEL_MEMORYMANAGER_H
-#define ULTIMA8_KERNEL_MEMORYMANAGER_H
-
-namespace Ultima {
-namespace Ultima8 {
-
-class Allocator;
-
-class MemoryManager {
-public:
-	MemoryManager();
-	~MemoryManager();
-
-	static MemoryManager *get_instance() {
-		return _memoryManager;
-	}
-
-	//! Allocates memory with the default allocator or malloc
-	static void *allocate(size_t size) {
-		return _memoryManager ? _memoryManager->_allocate(size) : 0;
-	}
-
-	//! Checks all known Allocators to free memory
-	static void deallocate(void *ptr) {
-		_memoryManager->_deallocate(ptr);
-	}
-
-	Allocator *getAllocator(uint16 index) {
-		return index < _allocatorCount ? _allocators[index] : 0;
-	}
-
-	uint16 getAllocatorCount() {
-		return _allocatorCount;
-	}
-
-	void freeResources();
-
-private:
-	Allocator *_allocators[10];
-	uint16 _allocatorCount;
-
-	void *_allocate(size_t size);
-	void _deallocate(void *ptr);
-
-	static MemoryManager *_memoryManager;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/kernel/object.cpp b/engines/ultima/ultima8/kernel/object.cpp
index a7b5f7455a..b2d6b01ec8 100644
--- a/engines/ultima/ultima8/kernel/object.cpp
+++ b/engines/ultima/ultima8/kernel/object.cpp
@@ -25,7 +25,6 @@
 #include "ultima/ultima8/kernel/kernel.h"
 #include "ultima/ultima8/kernel/object_manager.h"
 #include "ultima/ultima8/world/world.h"
-#include "ultima/ultima8/kernel/memory_manager.h"
 #include "ultima/ultima8/usecode/uc_process.h"
 #include "ultima/ultima8/usecode/uc_machine.h"
 
@@ -35,8 +34,6 @@ namespace Ultima8 {
 // p_dynamic_cast stuff
 DEFINE_RUNTIME_CLASSTYPE_CODE_BASE_CLASS(Object)
 
-DEFINE_CUSTOM_MEMORY_ALLOCATION(Object)
-
 Object::~Object() {
 	if (_objId != 0xFFFF)
 		ObjectManager::get_instance()->clearObjId(_objId);
diff --git a/engines/ultima/ultima8/kernel/object.h b/engines/ultima/ultima8/kernel/object.h
index b97208bb1e..87d8627050 100644
--- a/engines/ultima/ultima8/kernel/object.h
+++ b/engines/ultima/ultima8/kernel/object.h
@@ -39,9 +39,6 @@ public:
 	// p_dynamic_cast stuff
 	ENABLE_RUNTIME_CLASSTYPE_BASE()
 
-	// memory pooling stuff
-	ENABLE_CUSTOM_MEMORY_ALLOCATION()
-
 	//! get this Object's objID
 	inline ObjId getObjId() const {
 		return _objId;
diff --git a/engines/ultima/ultima8/kernel/pool.cpp b/engines/ultima/ultima8/kernel/pool.cpp
deleted file mode 100644
index 52cf63a969..0000000000
--- a/engines/ultima/ultima8/kernel/pool.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/kernel/pool.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-// p_dynamic_cast stuff
-DEFINE_RUNTIME_CLASSTYPE_CODE_BASE_CLASS(Pool)
-
-Pool::Pool() {
-}
-
-Pool::~Pool() {
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/kernel/pool.h b/engines/ultima/ultima8/kernel/pool.h
deleted file mode 100644
index ec2c0063a3..0000000000
--- a/engines/ultima/ultima8/kernel/pool.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_KERNEL_POOL_H
-#define ULTIMA8_KERNEL_POOL_H
-
-#include "ultima/ultima8/misc/p_dynamic_cast.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class Pool {
-public:
-	Pool();
-	virtual ~Pool();
-
-	// p_dynamic_cast stuff
-	ENABLE_RUNTIME_CLASSTYPE_BASE()
-
-	virtual void *allocate(size_t size) = 0;
-	virtual void deallocate(void *ptr) = 0;
-
-	virtual bool isFull() const = 0;
-	virtual bool isEmpty() const = 0;
-
-	virtual bool inPool(void *ptr) const = 0;
-
-	virtual void printInfo() const = 0;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/kernel/process.cpp b/engines/ultima/ultima8/kernel/process.cpp
index c8b7d12ce8..9449d6c0f1 100644
--- a/engines/ultima/ultima8/kernel/process.cpp
+++ b/engines/ultima/ultima8/kernel/process.cpp
@@ -30,8 +30,6 @@ namespace Ultima8 {
 // p_dynamic_cast stuff
 DEFINE_RUNTIME_CLASSTYPE_CODE_BASE_CLASS(Process)
 
-DEFINE_CUSTOM_MEMORY_ALLOCATION(Process)
-
 Process::Process(ObjId it, uint16 ty)
 	: _pid(0xFFFF), _flags(0), _itemNum(it), _type(ty), _result(0) {
 	Kernel::get_instance()->assignPID(this);
diff --git a/engines/ultima/ultima8/kernel/process.h b/engines/ultima/ultima8/kernel/process.h
index 346fce9979..b77215b8c6 100644
--- a/engines/ultima/ultima8/kernel/process.h
+++ b/engines/ultima/ultima8/kernel/process.h
@@ -44,9 +44,6 @@ public:
 	// p_dynamic_cast stuff
 	ENABLE_RUNTIME_CLASSTYPE_BASE()
 
-	// memory pooling stuff
-	ENABLE_CUSTOM_MEMORY_ALLOCATION()
-
 	uint32 getProcessFlags() const {
 		return _flags;
 	}
diff --git a/engines/ultima/ultima8/kernel/segmented_allocator.cpp b/engines/ultima/ultima8/kernel/segmented_allocator.cpp
deleted file mode 100644
index 4b30661c97..0000000000
--- a/engines/ultima/ultima8/kernel/segmented_allocator.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/kernel/segmented_allocator.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-DEFINE_RUNTIME_CLASSTYPE_CODE(SegmentedAllocator, Allocator)
-
-SegmentedAllocator::SegmentedAllocator(size_t nodeCapacity, uint32 nodes): Allocator(), _nodes(nodes) {
-	_pools.push_back(new SegmentedPool(nodeCapacity, nodes));
-	_nodeCapacity = _pools[0]->getNodeCapacity();
-//	pout << "Initial Pool Created: Nodes - " << _nodes << ", Node Capacity - "
-//		<< _nodeCapacity << Std::endl;
-}
-
-SegmentedAllocator::~SegmentedAllocator() {
-	Std::vector<SegmentedPool *>::iterator i;
-	for (i = _pools.begin(); i != _pools.end(); ++i) {
-		delete *i;
-	}
-
-	_pools.clear();
-}
-
-void *SegmentedAllocator::allocate(size_t size) {
-	Std::vector<SegmentedPool *>::iterator i;
-	SegmentedPool *p;
-
-	if (size > _nodeCapacity)
-		return nullptr;
-
-	for (i = _pools.begin(); i != _pools.end(); ++i) {
-		if (!(*i)->isFull())
-			return (*i)->allocate(size);
-	}
-
-	// else we need a new pool
-	p = new SegmentedPool(_nodeCapacity, _nodes);
-	if (p) {
-//		pout << "New Pool Created: Nodes - " << _nodes << ", Node Capacity - "
-//			<< _nodeCapacity << Std::endl;
-
-		_pools.push_back(p);
-		return p->allocate(size);
-	}
-
-	// fail
-	return nullptr;
-}
-
-Pool *SegmentedAllocator::findPool(void *ptr) {
-	Std::vector<SegmentedPool *>::iterator i;
-	for (i = _pools.begin(); i != _pools.end(); ++i) {
-		if ((*i)->inPool(ptr))
-			return *i;
-	}
-	return nullptr;
-}
-
-void SegmentedAllocator::freeResources() {
-	if (_pools.empty())
-		return;
-
-	// Pop back only -- it should suffice.
-	while (_pools.back()->isEmpty()) {
-		delete _pools.back();
-		_pools.pop_back();
-
-		if (_pools.empty())
-			return;
-	}
-}
-
-void SegmentedAllocator::printInfo() const {
-	Std::vector<SegmentedPool *>::const_iterator it;
-	int i = 0;
-
-	pout << "Pools: " <<  _pools.size() << Std::endl;
-	for (it = _pools.begin(); it != _pools.end(); ++it) {
-		pout << "  Pool " << i++ << ":" << Std::endl;
-		(*it)->printInfo();
-	}
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/kernel/segmented_allocator.h b/engines/ultima/ultima8/kernel/segmented_allocator.h
deleted file mode 100644
index 59443d9709..0000000000
--- a/engines/ultima/ultima8/kernel/segmented_allocator.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_KERNEL_SEGMENTED_ALLOCATOR_H
-#define ULTIMA8_KERNEL_SEGMENTED_ALLOCATOR_H
-
-#include "ultima/ultima8/kernel/allocator.h"
-#include "ultima/ultima8/kernel/segmented_pool.h"
-#include "ultima/shared/std/containers.h"
-#include "ultima/ultima8/misc/p_dynamic_cast.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class SegmentedAllocator: public Allocator {
-public:
-	SegmentedAllocator(size_t nodeCapacity, uint32 nodes);
-	~SegmentedAllocator() override;
-
-	ENABLE_RUNTIME_CLASSTYPE()
-
-	void *allocate(size_t size) override;
-
-	Pool *findPool(void *ptr) override;
-
-	void freeResources() override;
-
-	size_t getCapacity() override {
-		return _nodeCapacity;
-	}
-
-	void printInfo() const override;
-
-private:
-	Std::vector<SegmentedPool *> _pools;
-
-	size_t _nodeCapacity;
-	uint32 _nodes;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/kernel/segmented_pool.cpp b/engines/ultima/ultima8/kernel/segmented_pool.cpp
deleted file mode 100644
index 9fda22865d..0000000000
--- a/engines/ultima/ultima8/kernel/segmented_pool.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/kernel/segmented_pool.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-DEFINE_RUNTIME_CLASSTYPE_CODE(SegmentedPool, Pool)
-
-//	Memory is aligned to the next largest multiple of sizeof(x) from
-//  the base address plus the size. Although, this may not be very helpful
-//  if the base address is not a multiple of sizeof(X).
-//	example: sizeof(x) = 0x8, object size = 0xFFE2:
-//			0xFFE2 + 0x8 - 1 = 0xFFE9;
-//			0xFFE9 & ~(0x8 - 0x1) -> 0xFFE9 & 0xFFF8 = 0xFFE8
-
-#define OFFSET_ALIGN(X) ( (X + sizeof(uintptr) - 1) & ~(sizeof(uintptr) - 1) )
-
-struct SegmentedPoolNode {
-	SegmentedPool *pool;
-	SegmentedPoolNode *nextFree;
-	size_t size;
-};
-
-
-// We pad both the PoolNode and the memory to align it.
-
-SegmentedPool::SegmentedPool(size_t nodeCapacity_, uint32 nodes)
-	: Pool(), _nodes(nodes), _freeNodeCount(nodes) {
-	uint32 i;
-
-	// Give it its real capacity.
-	// One redzone is added after the memory block.
-	_nodeCapacity = OFFSET_ALIGN(nodeCapacity_);
-
-	// Node offsets are aligned to the next uintptr offset after the real size.
-	// Another redzone is added between the node and the memory block.
-	_nodeOffset = OFFSET_ALIGN(sizeof(SegmentedPoolNode)) + _nodeCapacity;
-
-	_startOfPool = new uint8[_nodeOffset * nodes];
-	_endOfPool = _startOfPool + (_nodeOffset * nodes);
-
-	_firstFree = reinterpret_cast<SegmentedPoolNode *>(_startOfPool);
-	_firstFree->pool = this;
-	_firstFree->size = 0;
-
-	_lastFree = _firstFree;
-
-	for (i = 1; i < nodes; ++i) {
-		_lastFree->nextFree = reinterpret_cast<SegmentedPoolNode *>(_startOfPool + i * _nodeOffset);
-		_lastFree = _lastFree->nextFree;
-
-		_lastFree->pool = this;
-		_lastFree->size = 0;
-	}
-
-	_lastFree->nextFree = 0;
-}
-
-SegmentedPool::~SegmentedPool() {
-	assert(isEmpty());
-
-	delete [] _startOfPool;
-}
-
-void *SegmentedPool::allocate(size_t size) {
-	SegmentedPoolNode *node;
-
-	if (isFull() || size > _nodeCapacity)
-		return nullptr;
-
-	--_freeNodeCount;
-	node = _firstFree;
-	node->size = size;
-
-	if (isFull()) {
-		_firstFree = nullptr;
-		_lastFree = nullptr;
-	} else {
-		_firstFree = _firstFree->nextFree;
-	}
-
-	node->nextFree = nullptr;
-
-//	debugN"Allocating Node 0x%08X\n", node);
-	uint8 *p = reinterpret_cast<uint8 *>(node) +
-	           OFFSET_ALIGN(sizeof(SegmentedPoolNode));
-
-	return p;
-}
-
-void SegmentedPool::deallocate(void *ptr) {
-	SegmentedPoolNode *node;
-
-	if (inPool(ptr)) {
-		node = getPoolNode(ptr);
-		node->size = 0;
-		assert(node->pool == this);
-
-//	debugN"Free Node 0x%08X\n", node);
-		if (isFull()) {
-			_firstFree = node;
-			_lastFree = node;
-		} else {
-			_lastFree->nextFree = node;
-			_lastFree = _lastFree->nextFree;
-		}
-		++_freeNodeCount;
-	}
-}
-
-void SegmentedPool::printInfo() const {
-	uint16 i;
-	uint32 max, min, total;
-	SegmentedPoolNode *node;
-
-	debug(MM_INFO, "start address 0x%p\tend address 0x%p\tnodeOffset 0x%x",
-		_startOfPool, _endOfPool, (uint32)_nodeOffset);
-	debug(MM_INFO, "_nodeCapacity %u b\n   total _nodes %u\tfree _nodes %u",
-		(uint32)_nodeCapacity, _nodes, _freeNodeCount);
-	debug(MM_INFO, "total memory: %u\tfree memory: %u",
-		(uint32)(_nodeCapacity * _nodes), (uint32)(_nodeCapacity * _freeNodeCount));
-
-	max = 0;
-	min = _nodeCapacity;
-	total = 0;
-
-	for (i = 0; i < _nodes; ++i) {
-		node = reinterpret_cast<SegmentedPoolNode *>(_startOfPool + i * _nodeOffset);
-		if (node->size > 0) {
-			max = node->size > max ? node->size : max;
-			min = node->size < min ? node->size : min;
-			total += node->size;
-		}
-	}
-
-	if (_nodes > _freeNodeCount) {
-		debug(MM_INFO, "smallest node: %u b\tlargest node: %u b\taverage size: %u b",
-			min, max, total / (_nodes - _freeNodeCount));
-	} else {
-		debug(MM_INFO, "Empty pool!!!");
-	}
-}
-
-SegmentedPoolNode *SegmentedPool::getPoolNode(void *ptr) {
-	uint32 pos = (reinterpret_cast<uint8 *>(ptr) - _startOfPool) / _nodeOffset;
-	return reinterpret_cast<SegmentedPoolNode *>(_startOfPool + pos * _nodeOffset);
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/kernel/segmented_pool.h b/engines/ultima/ultima8/kernel/segmented_pool.h
deleted file mode 100644
index 97b0bd0e19..0000000000
--- a/engines/ultima/ultima8/kernel/segmented_pool.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_KERNEL_SEGMENTED_POOL_H
-#define ULTIMA8_KERNEL_SEGMENTED_POOL_H
-
-#include "ultima/ultima8/kernel/pool.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-// Think about adding magic to the front of the
-// PoolNode to identify them.
-
-class SegmentedPool;
-
-struct SegmentedPoolNode;
-
-/**
- * A pool with memory broken into even length segments.
- * SegmentedPool only allocate memory one segment at a time.
- * If the requested memory is larger than a segment, allocation will fail
- * and return nullptr.
- */
-class SegmentedPool: public Pool {
-public:
-	SegmentedPool(size_t nodeCapacity, uint32 nodes);
-	~SegmentedPool() override;
-
-	ENABLE_RUNTIME_CLASSTYPE()
-
-	void *allocate(size_t size) override;
-	void deallocate(void *ptr) override;
-
-	bool isFull() const override {
-		return _freeNodeCount == 0;
-	}
-	bool isEmpty() const override {
-		return _freeNodeCount == _nodes;
-	}
-
-	bool inPool(void *ptr) const override {
-		return (ptr > _startOfPool && ptr < _endOfPool);
-	}
-
-	void printInfo() const override;
-
-	size_t getNodeCapacity() const {
-		return _nodeCapacity;
-	}
-
-	SegmentedPoolNode *getPoolNode(void *ptr);
-private:
-	uint8 *_startOfPool;
-	uint8 *_endOfPool;
-
-	size_t _nodeOffset;
-	size_t _nodeCapacity;
-	uint32 _nodes;
-	uint32 _freeNodeCount;
-
-	SegmentedPoolNode *_firstFree;
-	SegmentedPoolNode *_lastFree;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index a7faf8a53e..1ea5678f83 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -35,9 +35,7 @@
 #include "ultima/ultima8/gumps/quit_gump.h"
 #include "ultima/ultima8/gumps/shape_viewer_gump.h"
 #include "ultima/ultima8/gumps/menu_gump.h"
-#include "ultima/ultima8/kernel/allocator.h"
 #include "ultima/ultima8/kernel/kernel.h"
-#include "ultima/ultima8/kernel/memory_manager.h"
 #include "ultima/ultima8/kernel/object_manager.h"
 #include "ultima/ultima8/misc/id_man.h"
 #include "ultima/ultima8/misc/util.h"
@@ -119,11 +117,6 @@ Debugger::Debugger() : Shared::Debugger() {
 	registerCmd("MainActor::useKeyring", WRAP_METHOD(Debugger, cmdUseKeyring));
 	registerCmd("MainActor::toggleCombat", WRAP_METHOD(Debugger, cmdToggleCombat));
 
-	registerCmd("MemoryManager::MemInfo", WRAP_METHOD(Debugger, cmdMemInfo));
-#ifdef DEBUG
-	registerCmd("MemoryManager::test", WRAP_METHOD(Debugger, cmdTestMemory));
-#endif
-
 	registerCmd("ObjectManager::objectTypes", WRAP_METHOD(Debugger, cmdObjectTypes));
 	registerCmd("ObjectManager::objectInfo", WRAP_METHOD(Debugger, cmdObjectInfo));
 
@@ -1124,29 +1117,6 @@ bool Debugger::cmdToggleCombat(int argc, const char **argv) {
 	return false;
 }
 
-bool Debugger::cmdMemInfo(int argc, const char **argv) {
-	MemoryManager *mm = MemoryManager::get_instance();
-	int i, count;
-
-	if (mm) {
-		count = mm->getAllocatorCount();
-		debugPrintf("Allocators: %d\n", count);
-		for (i = 0; i < count; ++i) {
-			debugPrintf(" Allocator %d:\n", i);
-			mm->getAllocator(i)->printInfo();
-			debugPrintf("==============\n");
-		}
-	}
-
-	return true;
-}
-
-#ifdef DEBUG
-bool Debugger::cmdTestMemory(int argc, const char **argv) {
-	return true;
-}
-#endif
-
 bool Debugger::cmdObjectTypes(int argc, const char **argv) {
 	ObjectManager::get_instance()->objectTypes();
 	return true;
diff --git a/engines/ultima/ultima8/misc/debugger.h b/engines/ultima/ultima8/misc/debugger.h
index 16274a61bb..77d74ea45f 100644
--- a/engines/ultima/ultima8/misc/debugger.h
+++ b/engines/ultima/ultima8/misc/debugger.h
@@ -192,12 +192,6 @@ private:
 	bool cmdUseKeyring(int argc, const char **argv);
 	bool cmdToggleCombat(int argc, const char **argv);
 
-	// Memory Manager
-	bool cmdMemInfo(int argc, const char **argv);
-#ifdef DEBUG
-	bool cmdTestMemory(int argc, const char **argv);
-#endif
-
 	// Object Manager
 	bool cmdObjectTypes(int argc, const char **argv);
 	bool cmdObjectInfo(int argc, const char **argv);
diff --git a/engines/ultima/ultima8/misc/pent_include.cpp b/engines/ultima/ultima8/misc/pent_include.cpp
deleted file mode 100644
index 4c57b09c4a..0000000000
--- a/engines/ultima/ultima8/misc/pent_include.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-allocFunc palloc = malloc;
-deallocFunc pfree = free;
-
-void setAllocationFunctions(allocFunc a, deallocFunc d) {
-	palloc = a;
-	pfree = d;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/misc/pent_include.h b/engines/ultima/ultima8/misc/pent_include.h
index 7ee2bb0a42..f8a8173328 100644
--- a/engines/ultima/ultima8/misc/pent_include.h
+++ b/engines/ultima/ultima8/misc/pent_include.h
@@ -94,31 +94,4 @@
 //
 #define CANT_HAPPEN_MSG(msg) do { assert(msg && false); } while(0)
 
-namespace Ultima {
-namespace Ultima8 {
-
-// Memory Management through Allocators
-typedef void *(*allocFunc)(size_t size);
-typedef void (*deallocFunc)(void *ptr);
-
-extern allocFunc palloc;
-extern deallocFunc pfree;
-void setAllocationFunctions(allocFunc a, deallocFunc d);
-
-#define ENABLE_CUSTOM_MEMORY_ALLOCATION()                           \
-	static void * operator new(size_t size);                        \
-	static void operator delete(void * ptr);
-
-#define DEFINE_CUSTOM_MEMORY_ALLOCATION(Classname)                  \
-	void * Classname::operator new(size_t size) {                       \
-		return palloc(size);                                 \
-	}                                                                   \
-	\
-	void Classname::operator delete(void * ptr) {                       \
-		pfree(ptr);                                          \
-	}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
 #endif
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 248a9d72a4..f31a55ae20 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -40,7 +40,6 @@
 #include "ultima/ultima8/games/game_info.h"
 #include "ultima/ultima8/games/start_u8_process.h"
 #include "ultima/ultima8/graphics/fonts/font_manager.h"
-#include "ultima/ultima8/kernel/memory_manager.h"
 #include "ultima/ultima8/graphics/render_surface.h"
 #include "ultima/ultima8/graphics/texture.h"
 #include "ultima/ultima8/graphics/fonts/fixed_width_font.h"
@@ -141,7 +140,7 @@ Ultima8Engine::Ultima8Engine(OSystem *syst, const Ultima::UltimaGameDescription
 		_frameSkip(false), _frameLimit(true), _interpolate(true), _animationRate(100),
 		_avatarInStasis(false), _paintEditorItems(false), _inversion(0), _painting(false),
 		_showTouching(false), _timeOffset(0), _hasCheated(false), _cheatsEnabled(false),
-		_ttfOverrides(false), _audioMixer(0), _memoryManager(nullptr), _scalerGump(nullptr),
+		_ttfOverrides(false), _audioMixer(0), _scalerGump(nullptr),
 		_inverterGump(nullptr), _lerpFactor(256), _inBetweenFrame(false) {
 	_application = this;
 
@@ -164,7 +163,6 @@ Ultima8Engine::~Ultima8Engine() {
 	FORGET_OBJECT(_ucMachine);
 	FORGET_OBJECT(_fontManager);
 	FORGET_OBJECT(_screen);
-	FORGET_OBJECT(_memoryManager);
 }
 
 Common::Error Ultima8Engine::run() {
@@ -207,7 +205,6 @@ void Ultima8Engine::startup() {
 	_fileSystem->initBuiltinData(dataoverride);
 
 	_kernel = new Kernel();
-	_memoryManager = new MemoryManager();
 
 	//!! move this elsewhere
 	_kernel->addProcessLoader("DelayProcess",
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 2f7feddaf4..51dd75aee6 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -52,7 +52,6 @@ namespace Ultima8 {
 
 class Debugger;
 class Kernel;
-class MemoryManager;
 class UCMachine;
 class Game;
 class Gump;
@@ -87,7 +86,6 @@ private:
 	Std::string _errorTitle;
 
 	Kernel *_kernel;
-	MemoryManager *_memoryManager;
 	ObjectManager *_objectManager;
 	UCMachine *_ucMachine;
 	RenderSurface *_screen;
diff --git a/engines/ultima/ultima8/world/world.cpp b/engines/ultima/ultima8/world/world.cpp
index f2aed17bae..365c6a017f 100644
--- a/engines/ultima/ultima8/world/world.cpp
+++ b/engines/ultima/ultima8/world/world.cpp
@@ -38,7 +38,6 @@
 #include "ultima/ultima8/gumps/gump.h" // For CloseItemDependents notification
 #include "ultima/ultima8/world/actors/animation.h"
 #include "ultima/ultima8/world/get_object.h"
-#include "ultima/ultima8/kernel/memory_manager.h"
 #include "ultima/ultima8/audio/audio_process.h"
 #include "ultima/ultima8/filesys/idata_source.h"
 
@@ -179,8 +178,6 @@ bool World::switchMap(uint32 newmap) {
 	CameraProcess::SetCameraProcess(new CameraProcess(1));
 	CameraProcess::SetEarthquake(0);
 
-	MemoryManager::get_instance()->freeResources();
-
 	return true;
 }
 




More information about the Scummvm-git-logs mailing list