Lines Matching refs:allocator_

99     allocator_.reset(new FencedAllocator(kBufferSize, helper_.get()));
106 EXPECT_TRUE(allocator_->CheckConsistency());
111 scoped_ptr<FencedAllocator> allocator_;
116 allocator_->CheckConsistency();
117 EXPECT_FALSE(allocator_->InUse());
120 FencedAllocator::Offset offset = allocator_->Alloc(kSize);
121 EXPECT_TRUE(allocator_->InUse());
124 EXPECT_TRUE(allocator_->CheckConsistency());
126 allocator_->Free(offset);
127 EXPECT_FALSE(allocator_->InUse());
128 EXPECT_TRUE(allocator_->CheckConsistency());
133 FencedAllocator::Offset offset = allocator_->Alloc(0);
135 EXPECT_FALSE(allocator_->InUse());
136 EXPECT_TRUE(allocator_->CheckConsistency());
141 EXPECT_TRUE(allocator_->CheckConsistency());
150 offsets[i] = allocator_->Alloc(kSize);
153 EXPECT_TRUE(allocator_->CheckConsistency());
157 FencedAllocator::Offset offset_failed = allocator_->Alloc(kSize);
159 EXPECT_TRUE(allocator_->CheckConsistency());
162 allocator_->Free(offsets[0]);
163 EXPECT_TRUE(allocator_->CheckConsistency());
164 offsets[0] = allocator_->Alloc(kSize/2);
167 EXPECT_TRUE(allocator_->CheckConsistency());
170 offset_failed = allocator_->Alloc(kSize);
172 EXPECT_TRUE(allocator_->CheckConsistency());
176 allocator_->Free(offsets[i]);
177 EXPECT_TRUE(allocator_->CheckConsistency());
183 EXPECT_TRUE(allocator_->CheckConsistency());
192 offsets[i] = allocator_->Alloc(kSize);
195 EXPECT_TRUE(allocator_->CheckConsistency());
199 FencedAllocator::Offset offset_failed = allocator_->Alloc(kSize);
201 EXPECT_TRUE(allocator_->CheckConsistency());
205 allocator_->FreePendingToken(offsets[0], token);
206 EXPECT_TRUE(allocator_->CheckConsistency());
215 offsets[0] = allocator_->Alloc(kSize);
218 EXPECT_TRUE(allocator_->CheckConsistency());
224 allocator_->Free(offsets[i]);
225 EXPECT_TRUE(allocator_->CheckConsistency());
231 EXPECT_TRUE(allocator_->CheckConsistency());
240 offsets[i] = allocator_->Alloc(kSize);
243 EXPECT_TRUE(allocator_->CheckConsistency());
245 EXPECT_TRUE(allocator_->InUse());
248 EXPECT_EQ(0u, allocator_->GetLargestFreeSize());
252 allocator_->FreePendingToken(offsets[0], token);
253 EXPECT_TRUE(allocator_->CheckConsistency());
259 allocator_->FreeUnused();
262 EXPECT_EQ(kSize, allocator_->GetLargestFreeSize());
266 allocator_->FreePendingToken(offsets[1], token);
268 allocator_->FreePendingToken(offsets[2], token);
269 EXPECT_TRUE(allocator_->CheckConsistency());
272 EXPECT_EQ(kSize, allocator_->GetLargestFreeSize());
278 allocator_->FreeUnused();
281 EXPECT_EQ(kSize * 3, allocator_->GetLargestFreeSize());
282 EXPECT_TRUE(allocator_->InUse());
286 allocator_->Free(offsets[i]);
287 EXPECT_TRUE(allocator_->CheckConsistency());
289 EXPECT_FALSE(allocator_->InUse());
294 EXPECT_TRUE(allocator_->CheckConsistency());
295 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeSize());
297 FencedAllocator::Offset offset = allocator_->Alloc(kBufferSize);
299 EXPECT_EQ(0u, allocator_->GetLargestFreeSize());
300 allocator_->Free(offset);
301 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeSize());
304 offset = allocator_->Alloc(kSize);
309 EXPECT_EQ(kBufferSize - kSize, allocator_->GetLargestFreeSize());
314 FencedAllocator::Offset offset1 = allocator_->Alloc(kSize);
316 FencedAllocator::Offset offset2 = allocator_->Alloc(kSize);
318 allocator_->Free(offset);
319 allocator_->Free(offset1);
320 EXPECT_EQ(kBufferSize - 3 * kSize, allocator_->GetLargestFreeSize());
322 offset = allocator_->Alloc(kBufferSize - 3 * kSize);
324 EXPECT_EQ(2 * kSize, allocator_->GetLargestFreeSize());
326 offset1 = allocator_->Alloc(2 * kSize);
328 EXPECT_EQ(0u, allocator_->GetLargestFreeSize());
330 allocator_->Free(offset);
331 allocator_->Free(offset1);
332 allocator_->Free(offset2);
337 EXPECT_TRUE(allocator_->CheckConsistency());
338 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeOrPendingSize());
340 FencedAllocator::Offset offset = allocator_->Alloc(kBufferSize);
342 EXPECT_EQ(0u, allocator_->GetLargestFreeOrPendingSize());
343 allocator_->Free(offset);
344 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeOrPendingSize());
347 offset = allocator_->Alloc(kSize);
352 EXPECT_EQ(kBufferSize - kSize, allocator_->GetLargestFreeOrPendingSize());
357 FencedAllocator::Offset offset1 = allocator_->Alloc(kSize);
359 FencedAllocator::Offset offset2 = allocator_->Alloc(kSize);
361 allocator_->Free(offset);
362 allocator_->Free(offset1);
364 allocator_->GetLargestFreeOrPendingSize());
368 allocator_->FreePendingToken(offset2, token);
371 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeOrPendingSize());
374 allocator_->GetLargestFreeSize());
382 offset = allocator_->Alloc(kBufferSize);
386 allocator_->Free(offset);
389 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeOrPendingSize());
391 EXPECT_EQ(kBufferSize, allocator_->GetLargestFreeSize());
409 allocator_.reset(new FencedAllocatorWrapper(kBufferSize, helper_.get(),
417 EXPECT_TRUE(allocator_->CheckConsistency());
422 scoped_ptr<FencedAllocatorWrapper> allocator_;
428 allocator_->CheckConsistency();
431 void *pointer = allocator_->Alloc(kSize);
435 EXPECT_TRUE(allocator_->CheckConsistency());
437 allocator_->Free(pointer);
438 EXPECT_TRUE(allocator_->CheckConsistency());
440 char *pointer_char = allocator_->AllocTyped<char>(kSize);
444 allocator_->Free(pointer_char);
445 EXPECT_TRUE(allocator_->CheckConsistency());
447 unsigned int *pointer_uint = allocator_->AllocTyped<unsigned int>(kSize);
456 allocator_->GetLargestFreeSize());
457 allocator_->Free(pointer_uint);
462 allocator_->CheckConsistency();
464 void *pointer = allocator_->Alloc(0);
466 EXPECT_TRUE(allocator_->CheckConsistency());
471 allocator_->CheckConsistency();
474 void *pointer1 = allocator_->Alloc(kSize1);
477 EXPECT_TRUE(allocator_->CheckConsistency());
480 void *pointer2 = allocator_->Alloc(kSize2);
483 EXPECT_TRUE(allocator_->CheckConsistency());
485 allocator_->Free(pointer2);
486 EXPECT_TRUE(allocator_->CheckConsistency());
488 allocator_->Free(pointer1);
489 EXPECT_TRUE(allocator_->CheckConsistency());
494 allocator_->CheckConsistency();
503 pointers[i] = allocator_->Alloc(kSize);
505 EXPECT_TRUE(allocator_->CheckConsistency());
509 void *pointer_failed = allocator_->Alloc(kSize);
511 EXPECT_TRUE(allocator_->CheckConsistency());
514 allocator_->Free(pointers[0]);
515 EXPECT_TRUE(allocator_->CheckConsistency());
516 pointers[0] = allocator_->Alloc(kSize/2);
518 EXPECT_TRUE(allocator_->CheckConsistency());
521 pointer_failed = allocator_->Alloc(kSize);
523 EXPECT_TRUE(allocator_->CheckConsistency());
527 allocator_->Free(pointers[i]);
528 EXPECT_TRUE(allocator_->CheckConsistency());
534 allocator_->CheckConsistency();
543 pointers[i] = allocator_->Alloc(kSize);
545 EXPECT_TRUE(allocator_->CheckConsistency());
549 void *pointer_failed = allocator_->Alloc(kSize);
551 EXPECT_TRUE(allocator_->CheckConsistency());
555 allocator_->FreePendingToken(pointers[0], token);
556 EXPECT_TRUE(allocator_->CheckConsistency());
565 pointers[0] = allocator_->Alloc(kSize);
567 EXPECT_TRUE(allocator_->CheckConsistency());
573 allocator_->Free(pointers[i]);
574 EXPECT_TRUE(allocator_->CheckConsistency());