Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(920)

Unified Diff: test/cctest/test-list.cc

Issue 10448007: Split an allocation policy into an allocator and a deallocator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make TemplateHashMapImpl consistent with the rest of the approach. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/zone-inl.h ('K') | « src/zone-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« src/zone-inl.h ('K') | « src/zone-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698