Lines Matching defs:Alloc
18 BumpPtrAllocator Alloc;
19 int *a = (int*)Alloc.Allocate(sizeof(int), alignof(int));
20 int *b = (int*)Alloc.Allocate(sizeof(int) * 10, alignof(int));
21 int *c = (int*)Alloc.Allocate(sizeof(int), alignof(int));
30 EXPECT_EQ(1U, Alloc.GetNumSlabs());
32 BumpPtrAllocator Alloc2 = std::move(Alloc);
33 EXPECT_EQ(0U, Alloc.GetNumSlabs());
43 Alloc = std::move(Alloc2);
45 EXPECT_EQ(1U, Alloc.GetNumSlabs());
50 BumpPtrAllocator Alloc;
51 Alloc.Allocate(3000, 1);
52 EXPECT_EQ(1U, Alloc.GetNumSlabs());
53 Alloc.Allocate(3000, 1);
54 EXPECT_EQ(2U, Alloc.GetNumSlabs());
55 Alloc.Allocate(3000, 1);
56 EXPECT_EQ(3U, Alloc.GetNumSlabs());
62 BumpPtrAllocator Alloc;
65 (void)Alloc.Allocate(5000, 1);
66 Alloc.Reset();
68 EXPECT_EQ(0u, Alloc.GetNumSlabs());
70 Alloc.Allocate(3000, 1);
71 EXPECT_EQ(1U, Alloc.GetNumSlabs());
72 Alloc.Allocate(3000, 1);
73 EXPECT_EQ(2U, Alloc.GetNumSlabs());
74 Alloc.Reset();
75 EXPECT_EQ(1U, Alloc.GetNumSlabs());
76 Alloc.Allocate(3000, 1);
77 EXPECT_EQ(1U, Alloc.GetNumSlabs());
78 Alloc.Allocate(3000, 1);
79 EXPECT_EQ(2U, Alloc.GetNumSlabs());
84 BumpPtrAllocator Alloc;
86 a = (uintptr_t)Alloc.Allocate(1, 2);
88 a = (uintptr_t)Alloc.Allocate(1, 4);
90 a = (uintptr_t)Alloc.Allocate(1, 8);
92 a = (uintptr_t)Alloc.Allocate(1, 16);
94 a = (uintptr_t)Alloc.Allocate(1, 32);
96 a = (uintptr_t)Alloc.Allocate(1, 64);
98 a = (uintptr_t)Alloc.Allocate(1, 128);
107 BumpPtrAllocator Alloc;
108 Alloc.setRedZoneSize(0); // else our arithmetic is all off
109 EXPECT_EQ(0u, Alloc.GetNumSlabs());
110 EXPECT_EQ(0u, Alloc.getBytesAllocated());
112 void *Empty = Alloc.Allocate(0, 1);
114 EXPECT_EQ(1u, Alloc.GetNumSlabs()) << "Allocated a slab to point to";
115 EXPECT_EQ(0u, Alloc.getBytesAllocated());
117 void *Large = Alloc.Allocate(4096, 1);
118 EXPECT_EQ(1u, Alloc.GetNumSlabs());
119 EXPECT_EQ(4096u, Alloc.getBytesAllocated());
122 void *Empty2 = Alloc.Allocate(0, 1);
124 EXPECT_EQ(1u, Alloc.GetNumSlabs());
125 EXPECT_EQ(4096u, Alloc.getBytesAllocated());
131 BumpPtrAllocator Alloc;
134 Alloc.Allocate(4096, 1);
135 EXPECT_EQ(1U, Alloc.GetNumSlabs());
138 Alloc.Allocate(1, 1);
139 EXPECT_EQ(2U, Alloc.GetNumSlabs());
144 BumpPtrAllocator Alloc;
146 Alloc.Allocate(8000, 1);
147 EXPECT_EQ(1U, Alloc.GetNumSlabs());
152 BumpPtrAllocator Alloc;
153 Alloc.Allocate(4095, 1);
158 Alloc.Allocate(1024, 8192);
160 EXPECT_EQ(2U, Alloc.GetNumSlabs());
168 BumpPtrAllocatorImpl<MallocAllocator, SlabSize, SlabSize, GrowthDelay> Alloc;
171 Alloc.setRedZoneSize(0);
173 Alloc.Allocate(SlabSize, 1);
174 EXPECT_EQ(SlabSize, Alloc.getTotalMemory());
177 Alloc.Allocate(SlabSize, 1);
178 EXPECT_EQ(SlabSize * 3, Alloc.getTotalMemory());
179 Alloc.Allocate(SlabSize, 1);
180 EXPECT_EQ(SlabSize * 3, Alloc.getTotalMemory());
186 Alloc.Allocate(SlabSize, 1);
187 EXPECT_EQ(SlabSize * 7, Alloc.getTotalMemory());
195 BumpPtrAllocatorImpl<MallocAllocator, SlabSize, SlabSize, GrowthDelay> Alloc;
198 Alloc.setRedZoneSize(0);
203 Alloc.Allocate(SlabSize, 1);
204 EXPECT_EQ(SlabSize * GrowthDelay, Alloc.getTotalMemory());
207 Alloc.Allocate(SlabSize, 1);
208 EXPECT_EQ(SlabSize * GrowthDelay + SlabSize * 2, Alloc.getTotalMemory());
212 BumpPtrAllocator Alloc;
214 uint64_t *a = (uint64_t *)Alloc.Allocate(sizeof(uint64_t), alignof(uint64_t));
215 std::optional<int64_t> maybe_a_belongs = Alloc.identifyObject(a);
220 std::optional<int64_t> maybe_b_belongs = Alloc.identifyObject(b);
226 (uint64_t *)Alloc.Allocate(sizeof(uint64_t) * 1024, alignof(uint64_t));
227 std::optional<int64_t> maybe_c_belongs = Alloc.identifyObject(c);
269 BumpPtrAllocatorImpl<MockSlabAllocator> Alloc;
272 (void)Alloc.Allocate(1, 1);
275 (void)Alloc.Allocate(3000, 2048);