From d99745be21ad9affc7e127944556c74da07440c4 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 19 Dec 2010 10:16:37 +0000 Subject: 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 --- tests/allocator.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/allocator.cpp') 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(align_to_page(reinterpret_cast(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(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(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(result) + 1; } size_t memory_size(void* ptr) { size_t result; - memcpy(&result, (size_t*)ptr - 1, sizeof(size_t)); + memcpy(&result, static_cast(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(ptr) - 1, size + sizeof(size_t)); } -- cgit v1.2.3