summaryrefslogtreecommitdiff
path: root/linker/linker_block_allocator.cpp
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2019-01-31 03:54:23 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-01-31 03:54:23 +0000
commitfcb35dc4aa07239878c8ba987aff739388b0f15f (patch)
treee933b87886c7949f51b3094c6d76de02fe6a22e0 /linker/linker_block_allocator.cpp
parentccc0922653904525147b670f0aa25aa85c0d2022 (diff)
parent7bb60fcbcd29f4e18865aa657cb3929ecb872b77 (diff)
Merge "Revert "linker: Purge block allocator memory when possible""
Diffstat (limited to 'linker/linker_block_allocator.cpp')
-rw-r--r--linker/linker_block_allocator.cpp25
1 files changed, 1 insertions, 24 deletions
diff --git a/linker/linker_block_allocator.cpp b/linker/linker_block_allocator.cpp
index 27f1e3800..d72cad3d6 100644
--- a/linker/linker_block_allocator.cpp
+++ b/linker/linker_block_allocator.cpp
@@ -55,8 +55,7 @@ LinkerBlockAllocator::LinkerBlockAllocator(size_t block_size)
: block_size_(
round_up(block_size < sizeof(FreeBlockInfo) ? sizeof(FreeBlockInfo) : block_size, 16)),
page_list_(nullptr),
- free_block_list_(nullptr),
- allocated_(0)
+ free_block_list_(nullptr)
{}
void* LinkerBlockAllocator::alloc() {
@@ -77,8 +76,6 @@ void* LinkerBlockAllocator::alloc() {
memset(block_info, 0, block_size_);
- ++allocated_;
-
return block_info;
}
@@ -107,11 +104,6 @@ void LinkerBlockAllocator::free(void* block) {
block_info->num_free_blocks = 1;
free_block_list_ = block_info;
-
- --allocated_;
- if (allocated_ == 0) {
- free_all_pages();
- }
}
void LinkerBlockAllocator::protect_all(int prot) {
@@ -162,18 +154,3 @@ LinkerBlockAllocatorPage* LinkerBlockAllocator::find_page(void* block) {
abort();
}
-
-void LinkerBlockAllocator::free_all_pages() {
- if (allocated_) {
- abort();
- }
-
- LinkerBlockAllocatorPage* page = page_list_;
- while (page) {
- LinkerBlockAllocatorPage* next = page->next;
- munmap(page, kAllocateSize);
- page = next;
- }
- page_list_ = nullptr;
- free_block_list_ = nullptr;
-}