aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2008-03-30 18:53:16 +0000
committerTorbjörn Andersson2008-03-30 18:53:16 +0000
commita03547dc8ec08d6497cade6a39808cd411ac3af9 (patch)
tree53f019dd051eda1a09ceaf3040d99251c00a2492
parentbd85909ff998150a6a238ad04a554f5024faa6ef (diff)
downloadscummvm-rg350-a03547dc8ec08d6497cade6a39808cd411ac3af9.tar.gz
scummvm-rg350-a03547dc8ec08d6497cade6a39808cd411ac3af9.tar.bz2
scummvm-rg350-a03547dc8ec08d6497cade6a39808cd411ac3af9.zip
Some minor whitespace changes, and the customary "end of namespace" comment.
svn-id: r31338
-rw-r--r--common/memorypool.cpp23
-rw-r--r--common/memorypool.h8
2 files changed, 14 insertions, 17 deletions
diff --git a/common/memorypool.cpp b/common/memorypool.cpp
index 6eab758c11..b5daeee496 100644
--- a/common/memorypool.cpp
+++ b/common/memorypool.cpp
@@ -26,8 +26,7 @@
#include "common/memorypool.h"
#include "common/util.h"
-namespace Common
-{
+namespace Common {
static const size_t CHUNK_PAGE_SIZE = 32;
@@ -35,7 +34,7 @@ void* MemoryPool::allocPage() {
void* result = ::malloc(CHUNK_PAGE_SIZE * _chunkSize);
_pages.push_back(result);
void* current = result;
- for(size_t i=1; i<CHUNK_PAGE_SIZE; ++i) {
+ for (size_t i = 1; i < CHUNK_PAGE_SIZE; ++i) {
void* next = ((char*)current + _chunkSize);
*(void**)current = next;
@@ -56,13 +55,13 @@ MemoryPool::MemoryPool(size_t chunkSize) {
}
MemoryPool::~MemoryPool() {
- for(size_t i=0; i<_pages.size(); ++i)
+ for (size_t i = 0; i<_pages.size(); ++i)
::free(_pages[i]);
}
void* MemoryPool::malloc() {
#if 1
- if(!_next)
+ if (!_next)
_next = allocPage();
void* result = _next;
@@ -91,15 +90,15 @@ void MemoryPool::freeUnusedPages() {
//std::sort(_pages.begin(), _pages.end());
Array<size_t> numberOfFreeChunksPerPage;
numberOfFreeChunksPerPage.resize(_pages.size());
- for(size_t i=0; i<numberOfFreeChunksPerPage.size(); ++i) {
+ for (size_t i = 0; i < numberOfFreeChunksPerPage.size(); ++i) {
numberOfFreeChunksPerPage[i] = 0;
}
void* iterator = _next;
- while(iterator) {
+ while (iterator) {
// This should be a binary search
- for(size_t i=0; i<_pages.size(); ++i) {
- if(isPointerInPage(iterator, _pages[i])) {
+ for (size_t i = 0; i < _pages.size(); ++i) {
+ if (isPointerInPage(iterator, _pages[i])) {
++numberOfFreeChunksPerPage[i];
break;
}
@@ -108,8 +107,8 @@ void MemoryPool::freeUnusedPages() {
}
size_t freedPagesCount = 0;
- for(size_t i=0; i<_pages.size(); ++i) {
- if(numberOfFreeChunksPerPage[i] == CHUNK_PAGE_SIZE) {
+ for (size_t i = 0; i < _pages.size(); ++i) {
+ if (numberOfFreeChunksPerPage[i] == CHUNK_PAGE_SIZE) {
::free(_pages[i]);
_pages[i] = NULL; // TODO : Remove NULL values
++freedPagesCount;
@@ -119,4 +118,4 @@ void MemoryPool::freeUnusedPages() {
//printf("%d freed pages\n", freedPagesCount);
}
-}
+} // End of namespace Common
diff --git a/common/memorypool.h b/common/memorypool.h
index 9ecab9e90b..fcbacabc5c 100644
--- a/common/memorypool.h
+++ b/common/memorypool.h
@@ -29,11 +29,9 @@
#include "common/scummsys.h"
#include "common/array.h"
-namespace Common
-{
+namespace Common {
-class MemoryPool
-{
+class MemoryPool {
private:
MemoryPool(const MemoryPool&);
MemoryPool& operator=(const MemoryPool&);
@@ -54,6 +52,6 @@ public:
void freeUnusedPages();
};
-}
+} // End of namespace Common
#endif