[Scummvm-cvs-logs] SF.net SVN: scummvm:[55012] scummvm/trunk/backends/plugins/elf
Bluddy at users.sourceforge.net
Bluddy at users.sourceforge.net
Wed Dec 22 16:33:46 CET 2010
Revision: 55012
http://scummvm.svn.sourceforge.net/scummvm/?rev=55012&view=rev
Author: Bluddy
Date: 2010-12-22 15:33:46 +0000 (Wed, 22 Dec 2010)
Log Message:
-----------
PLUGINS: replace all size_t's with uint32's and add #include <malloc.h> to memory manager
uint32 is all we need since we only handle ELF32 anyway.
Modified Paths:
--------------
scummvm/trunk/backends/plugins/elf/memory-manager.cpp
scummvm/trunk/backends/plugins/elf/memory-manager.h
Modified: scummvm/trunk/backends/plugins/elf/memory-manager.cpp
===================================================================
--- scummvm/trunk/backends/plugins/elf/memory-manager.cpp 2010-12-22 15:09:42 UTC (rev 55011)
+++ scummvm/trunk/backends/plugins/elf/memory-manager.cpp 2010-12-22 15:33:46 UTC (rev 55012)
@@ -28,7 +28,8 @@
#if defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER)
#include "backends/plugins/elf/memory-manager.h"
-#include "common/util.h"
+#include "common/util.h"
+#include <malloc.h>
DECLARE_SINGLETON(ELFMemoryManager);
@@ -56,7 +57,7 @@
} else { // we're done measuring
// get the total allocated size
- size_t measuredSize = _allocList.back().end() - _allocList.front().start;
+ uint32 measuredSize = _allocList.back().end() - _allocList.front().start;
_heapSize = MAX(_heapSize, measuredSize);
_heapAlign = MAX(_heapAlign, _measuredAlign);
@@ -68,7 +69,7 @@
}
}
-void ELFMemoryManager::trackAlloc(size_t align, size_t size) {
+void ELFMemoryManager::trackAlloc(uint32 align, uint32 size) {
if (!_measuredAlign)
_measuredAlign = align;
@@ -97,14 +98,14 @@
assert(_heap);
}
-void *ELFMemoryManager::pluginAllocate(size_t size) {
+void *ELFMemoryManager::pluginAllocate(uint32 size) {
if (_heap) {
return pluginAllocate(sizeof(void *), size);
}
return ::malloc(size);
}
-void *ELFMemoryManager::pluginAllocate(size_t align, size_t size) {
+void *ELFMemoryManager::pluginAllocate(uint32 align, uint32 size) {
if (_heap) {
return allocateOnHeap(align, size);
}
@@ -119,7 +120,7 @@
}
// Allocate space for the request in our heap
-void *ELFMemoryManager::allocateOnHeap(size_t align, size_t size) {
+void *ELFMemoryManager::allocateOnHeap(uint32 align, uint32 size) {
byte *lastAddress = (byte *)_heap;
// We can't allow allocations smaller than sizeof(Allocation). This could
@@ -135,13 +136,13 @@
lastAddress = i->end();
// align to desired alignment
if (align) {
- lastAddress = (byte *)( ((size_t)lastAddress + align - 1) & ~(align - 1) );
+ lastAddress = (byte *)( ((uint32)lastAddress + align - 1) & ~(align - 1) );
}
}
// Check if we exceeded our heap limit
// We skip this case if we're only tracking allocations
- if (!_trackAllocs && ((size_t)lastAddress + size > (size_t)_heap + _heapSize)) {
+ if (!_trackAllocs && ((uint32)lastAddress + size > (uint32)_heap + _heapSize)) {
debug(2, "failed to find space to allocate %d bytes", size);
return 0;
}
Modified: scummvm/trunk/backends/plugins/elf/memory-manager.h
===================================================================
--- scummvm/trunk/backends/plugins/elf/memory-manager.h 2010-12-22 15:09:42 UTC (rev 55011)
+++ scummvm/trunk/backends/plugins/elf/memory-manager.h 2010-12-22 15:33:46 UTC (rev 55012)
@@ -45,12 +45,12 @@
class ELFMemoryManager : public Common::Singleton<ELFMemoryManager> {
public:
void trackPlugin(bool value);
- void trackAlloc(size_t align, size_t size);
+ void trackAlloc(uint32 align, uint32 size);
void allocateHeap();
- void *pluginAllocate(size_t size);
- void *pluginAllocate(size_t align, size_t size);
+ void *pluginAllocate(uint32 size);
+ void *pluginAllocate(uint32 align, uint32 size);
void pluginDeallocate(void *ptr);
private:
@@ -59,25 +59,25 @@
ELFMemoryManager();
~ELFMemoryManager();
- void *allocateOnHeap(size_t align, size_t size);
+ void *allocateOnHeap(uint32 align, uint32 size);
void deallocateFromHeap(void *ptr);
struct Allocation {
byte *start;
- size_t size;
+ uint32 size;
byte *end() { return start + size; }
- Allocation(byte *a, size_t b) : start(a), size(b) {}
+ Allocation(byte *a, uint32 b) : start(a), size(b) {}
};
// heap
void *_heap;
- size_t _heapAlign; // alignment of the heap
- size_t _heapSize; // size of the heap
+ uint32 _heapAlign; // alignment of the heap
+ uint32 _heapSize; // size of the heap
// tracking allocations
bool _trackAllocs; // whether we are currently tracking
- size_t _measuredSize;
- size_t _measuredAlign;
+ uint32 _measuredSize;
+ uint32 _measuredAlign;
// real allocations
Common::List<Allocation> _allocList;
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