llvm.org GIT mirror llvm / 61760ce
BumpPtrAllocator: remove 'no slabs allocated yet' check We already handle the no-slabs case when checking whether the current slab is large enough: if no slabs have been allocated, CurPtr and End are both 0. alignPtr(0), will still be 0, and so "if (Ptr + Size <= End)" fails. Differential Revision: http://reviews.llvm.org/D4943 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215841 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 6 years ago
2 changed file(s) with 1 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
200200
201201 /// \brief Allocate space at the specified alignment.
202202 void *Allocate(size_t Size, size_t Alignment) {
203 if (!CurPtr) // Start a new slab if we haven't allocated one already.
204 StartNewSlab();
205
206203 // Keep track of how many bytes we've allocated.
207204 BytesAllocated += Size;
208205
111111 BumpPtrAllocator Alloc;
112112
113113 Alloc.Allocate(8000, 0);
114 EXPECT_EQ(2U, Alloc.GetNumSlabs());
114 EXPECT_EQ(1U, Alloc.GetNumSlabs());
115115 }
116116
117117 // Mock slab allocator that returns slabs aligned on 4096 bytes. There is no