summaryrefslogtreecommitdiff
path: root/Runtime/Allocator/LinearAllocator.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Allocator/LinearAllocator.cpp
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/Allocator/LinearAllocator.cpp')
-rw-r--r--Runtime/Allocator/LinearAllocator.cpp38
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