diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Allocator/LinearAllocator.cpp |
Diffstat (limited to 'Runtime/Allocator/LinearAllocator.cpp')
-rw-r--r-- | Runtime/Allocator/LinearAllocator.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Runtime/Allocator/LinearAllocator.cpp b/Runtime/Allocator/LinearAllocator.cpp new file mode 100644 index 0000000..9d0b23b --- /dev/null +++ b/Runtime/Allocator/LinearAllocator.cpp @@ -0,0 +1,38 @@ +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" +#include "LinearAllocator.h" + + +#if 0 + +struct FwdAllocatorMarker { + FwdAllocatorMarker (ForwardLinearAllocator& al) : al_(al), p_(al.current ()) {} + ~FwdAllocatorMarker () { al_.rewind (p_); } + + void* p_; + ForwardLinearAllocator& al_; +}; + + +void TestLinearAllocator () +{ + ForwardLinearAllocator la (32); + + void* p0 = la.allocate (16); + void* p1 = la.allocate (16); + + { + FwdAllocatorMarker m (la); + void* p2 = la.allocate (32); + } + + void* c1 = la.current (); + { + FwdAllocatorMarker m (la); + void* p3 = la.allocate (8); + void* p4 = la.allocate (32); + void* p5 = la.allocate (32); + } + la.rewind (c1); +} +#endif |