Chromium Code Reviews| Index: test/cctest/test-list.cc |
| diff --git a/test/cctest/test-list.cc b/test/cctest/test-list.cc |
| index 4c78f02cee1e0bae1bbcb03b9986e461b6a6354c..191b6a08793a0656f4c2a89b6798b20363307443 100644 |
| --- a/test/cctest/test-list.cc |
| +++ b/test/cctest/test-list.cc |
| @@ -28,14 +28,15 @@ |
| #include <stdlib.h> |
| #include <string.h> |
| #include "v8.h" |
| +#include "allocation.h" |
| #include "cctest.h" |
| using namespace v8::internal; |
| // Use a testing allocator that clears memory before deletion. |
| -class ZeroingAllocationPolicy { |
| +class ZeroingAllocator { |
| public: |
| - static void* New(size_t size) { |
| + void* New(size_t size) { |
| // Stash the size in the first word to use for Delete. |
| size_t true_size = size + sizeof(size_t); |
| size_t* result = reinterpret_cast<size_t*>(malloc(true_size)); |
| @@ -43,14 +44,24 @@ class ZeroingAllocationPolicy { |
| *result = true_size; |
| return result + 1; |
| } |
| +}; |
| + |
| - static void Delete(void* ptr) { |
| +class ZeroingDeallocator { |
| + public: |
| + void Delete(void* ptr) { |
| size_t* true_ptr = reinterpret_cast<size_t*>(ptr) - 1; |
| memset(true_ptr, 0, *true_ptr); |
| free(true_ptr); |
| } |
| }; |
| + |
| +struct ZeroingAllocationPolicy { |
| + typedef ZeroingAllocator Alloc; |
|
danno
2012/05/25 11:03:37
Full "Allocator" and "Deallocator"
|
| + typedef ZeroingDeallocator Dealloc; |
| +}; |
| + |
| // Check that we can add (a reference to) an element of the list |
| // itself. |
| TEST(ListAdd) { |