summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:20:27 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:20:27 +0000
commitea0dbe78843fa8b5e4c1d3f247383e38fb2348ef (patch)
tree124e98db3add93799253ed6de3de2f55cd12c0dd
parenta33c030d60722d35b1896596795d99b30ba91477 (diff)
tests: Deallocation of null pointer is illegal for custom allocators
git-svn-id: http://pugixml.googlecode.com/svn/trunk@656 99668b35-9821-0410-8761-19e4c4f06640
-rw-r--r--tests/main.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index 2af0a55..dc2a487 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -6,6 +6,7 @@
#include <iostream>
#include <stdio.h>
#include <float.h>
+#include <assert.h>
test_runner* test_runner::_tests = 0;
size_t test_runner::_memory_fail_threshold = 0;
@@ -32,13 +33,12 @@ static void* custom_allocate(size_t size)
static void custom_deallocate(void* ptr)
{
- if (ptr)
- {
- g_memory_total_size -= memory_size(ptr);
- g_memory_total_count--;
-
- memory_deallocate(ptr);
- }
+ assert(ptr);
+
+ g_memory_total_size -= memory_size(ptr);
+ g_memory_total_count--;
+
+ memory_deallocate(ptr);
}
static void replace_memory_management()
@@ -89,22 +89,22 @@ void* operator new[](size_t size, const std::nothrow_t&) throw()
void operator delete(void* ptr) DECL_NOTHROW()
{
- custom_deallocate(ptr);
+ if (ptr) custom_deallocate(ptr);
}
void operator delete[](void* ptr) DECL_NOTHROW()
{
- custom_deallocate(ptr);
+ if (ptr) custom_deallocate(ptr);
}
void operator delete(void* ptr, const std::nothrow_t&) throw()
{
- custom_deallocate(ptr);
+ if (ptr) custom_deallocate(ptr);
}
void operator delete[](void* ptr, const std::nothrow_t&) throw()
{
- custom_deallocate(ptr);
+ if (ptr) custom_deallocate(ptr);
}
#if defined(_MSC_VER) && _MSC_VER > 1200 && _MSC_VER < 1400 && !defined(__INTEL_COMPILER) && !defined(__DMC__)