From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Allocator/LinearAllocator.cpp | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Runtime/Allocator/LinearAllocator.cpp (limited to 'Runtime/Allocator/LinearAllocator.cpp') 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 -- cgit v1.1-26-g67d0