Attaches a scratch arena and returns the heap that backs its memory
| 41 | |
| 42 | // Attaches a scratch arena and returns the heap that backs its memory |
| 43 | Heap* ScratchArenaManager::attach(ScratchArena* arena) |
| 44 | { |
| 45 | Alloc& alloc = allocs[arena->name]; |
| 46 | |
| 47 | if (alloc.heap) |
| 48 | { |
| 49 | // Increase the size of the heap if necessary |
| 50 | if (arena->byteSize > alloc.heap->getByteSize()) |
| 51 | alloc.heap->realloc(arena->byteSize); |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | // Allocate a new heap |
| 56 | alloc.heap = engine->newHeap(arena->byteSize, Storage::Device); |
| 57 | } |
| 58 | |
| 59 | alloc.arenas.insert(arena); |
| 60 | return alloc.heap.get(); |
| 61 | } |
| 62 | |
| 63 | // Detaches the scratch arena |
| 64 | void ScratchArenaManager::detach(ScratchArena* arena) |
no test coverage detected