summaryrefslogtreecommitdiff
path: root/tests/allocator.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-12-19 10:16:37 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-12-19 10:16:37 +0000
commitd99745be21ad9affc7e127944556c74da07440c4 (patch)
treeb892303531af3f3775aeaa01799f2cb691a6d0f4 /tests/allocator.cpp
parent5720761685a1abc8ae0b5840a62359d35838ac3b (diff)
Enabled many additional GCC warnings (most notably -Wshadow and -Wold-style-cast), fixed the code accordingly
git-svn-id: http://pugixml.googlecode.com/svn/trunk@800 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/allocator.cpp')
-rw-r--r--tests/allocator.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/allocator.cpp b/tests/allocator.cpp
index b90820e..fcd8f2d 100644
--- a/tests/allocator.cpp
+++ b/tests/allocator.cpp
@@ -33,7 +33,7 @@ namespace
void* result = HeapAlloc(heap, 0, size + PAGE_SIZE);
- return (void*)align_to_page((size_t)result);
+ return reinterpret_cast<void*>(align_to_page(reinterpret_cast<size_t>(result)));
}
void* allocate(size_t size)
@@ -43,19 +43,19 @@ namespace
void* ptr = allocate_page_aligned(aligned_size + PAGE_SIZE);
if (!ptr) return 0;
- void* end = (char*)ptr + aligned_size;
+ char* end = static_cast<char*>(ptr) + aligned_size;
DWORD old_flags;
VirtualProtect(end, PAGE_SIZE, PAGE_NOACCESS, &old_flags);
- return (char*)end - size;
+ return end - size;
}
void deallocate(void* ptr, size_t size)
{
size_t aligned_size = align_to_page(size);
- void* rptr = (char*)ptr + size - aligned_size;
+ void* rptr = static_cast<char*>(ptr) + size - aligned_size;
DWORD old_flags;
VirtualProtect(rptr, aligned_size + PAGE_SIZE, PAGE_NOACCESS, &old_flags);
@@ -88,13 +88,13 @@ void* memory_allocate(size_t size)
memcpy(result, &size, sizeof(size_t));
- return (size_t*)result + 1;
+ return static_cast<size_t*>(result) + 1;
}
size_t memory_size(void* ptr)
{
size_t result;
- memcpy(&result, (size_t*)ptr - 1, sizeof(size_t));
+ memcpy(&result, static_cast<size_t*>(ptr) - 1, sizeof(size_t));
return result;
}
@@ -105,6 +105,6 @@ void memory_deallocate(void* ptr)
size_t size = memory_size(ptr);
- deallocate((size_t*)ptr - 1, size + sizeof(size_t));
+ deallocate(static_cast<size_t*>(ptr) - 1, size + sizeof(size_t));
}