[Scummvm-cvs-logs] SF.net SVN: scummvm:[48313] scummvm/trunk/common

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Mar 20 14:18:48 CET 2010


Revision: 48313
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48313&view=rev
Author:   lordhoto
Date:     2010-03-20 13:18:47 +0000 (Sat, 20 Mar 2010)

Log Message:
-----------
Some style fixes.

Modified Paths:
--------------
    scummvm/trunk/common/memorypool.cpp
    scummvm/trunk/common/memorypool.h

Modified: scummvm/trunk/common/memorypool.cpp
===================================================================
--- scummvm/trunk/common/memorypool.cpp	2010-03-20 13:00:23 UTC (rev 48312)
+++ scummvm/trunk/common/memorypool.cpp	2010-03-20 13:18:47 UTC (rev 48313)
@@ -34,10 +34,10 @@
 
 static size_t adjustChunkSize(size_t chunkSize) {
 	// You must at least fit the pointer in the node (technically unneeded considering the next rounding statement)
-	chunkSize = MAX(chunkSize, sizeof(void*));
+	chunkSize = MAX(chunkSize, sizeof(void *));
 	// There might be an alignment problem on some platforms when trying to load a void* on a non natural boundary
 	// so we round to the next sizeof(void*)
-	chunkSize = (chunkSize + sizeof(void*) - 1) & (~(sizeof(void*) - 1));
+	chunkSize = (chunkSize + sizeof(void *) - 1) & (~(sizeof(void *) - 1));
 
 	return chunkSize;
 }
@@ -82,42 +82,42 @@
 }
 
 void MemoryPool::addPageToPool(const Page &page) {
-
 	// Add all chunks of the new page to the linked list (pool) of free chunks
 	void *current = page.start;
 	for (size_t i = 1; i < page.numChunks; ++i) {
-		void *next    = ((char*)current + _chunkSize);
+		void *next = (byte *)current + _chunkSize;
 		*(void **)current = next;
 
 		current = next;
 	}
 
 	// Last chunk points to the old _next
-	*(void**)current = _next;
+	*(void **)current = _next;
 
 	// From now on, the first free chunk is the first chunk of the new page
 	_next = page.start;
 }
 
 void *MemoryPool::allocChunk() {
-	if (!_next)	// No free chunks left? Allocate a new page
+	// No free chunks left? Allocate a new page
+	if (!_next)
 		allocPage();
 
 	assert(_next);
 	void *result = _next;
-	_next = *(void**)result;
+	_next = *(void **)result;
 	return result;
 }
 
 void MemoryPool::freeChunk(void *ptr) {
 	// Add the chunk back to (the start of) the list of free chunks
-	*(void**)ptr = _next;
+	*(void **)ptr = _next;
 	_next = ptr;
 }
 
 // Technically not compliant C++ to compare unrelated pointers. In practice...
 bool MemoryPool::isPointerInPage(void *ptr, const Page &page) {
-	return (ptr >= page.start) && (ptr < (char*)page.start + page.numChunks * _chunkSize);
+	return (ptr >= page.start) && (ptr < (char *)page.start + page.numChunks * _chunkSize);
 }
 
 void MemoryPool::freeUnusedPages() {
@@ -138,7 +138,8 @@
 				break;
 			}
 		}
-		iterator = *(void**)iterator;
+
+		iterator = *(void **)iterator;
 	}
 
 	// Free all pages which are not in use.
@@ -149,10 +150,11 @@
 			void **iter2 = &_next;
 			while (*iter2) {
 				if (isPointerInPage(*iter2, _pages[i]))
-					*iter2 = **(void***)iter2;
+					*iter2 = **(void ***)iter2;
 				else
-					iter2 = *(void***)iter2;
+					iter2 = *(void ***)iter2;
 			}
+
 			::free(_pages[i].start);
 			++freedPagesCount;
 			_pages[i].start = NULL;
@@ -180,4 +182,5 @@
 	}
 }
 
-}	// End of namespace Common
+} // End of namespace Common
+

Modified: scummvm/trunk/common/memorypool.h
===================================================================
--- scummvm/trunk/common/memorypool.h	2010-03-20 13:00:23 UTC (rev 48312)
+++ scummvm/trunk/common/memorypool.h	2010-03-20 13:18:47 UTC (rev 48313)
@@ -154,12 +154,12 @@
  * For details on using placement new for custom allocators, see e.g.
  * <http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.14>
  */
-inline void* operator new(size_t nbytes, Common::MemoryPool& pool) {
+inline void *operator new(size_t nbytes, Common::MemoryPool &pool) {
 	assert(nbytes <= pool.getChunkSize());
 	return pool.allocChunk();
 }
 
-inline void operator delete(void* p, Common::MemoryPool& pool) {
+inline void operator delete(void *p, Common::MemoryPool &pool) {
 	pool.freeChunk(p);
 }
 


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