From 1e618e16ee25ab98b92b6e2d6c910a155505c140 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 11 May 2013 21:45:44 -0400 Subject: [PATCH] VM: Refactor bump_allocator.hpp to Factor style --- vm/bump_allocator.hpp | 73 ++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 43 deletions(-) diff --git a/vm/bump_allocator.hpp b/vm/bump_allocator.hpp index bbe4df8eec..d33ce80102 100644 --- a/vm/bump_allocator.hpp +++ b/vm/bump_allocator.hpp @@ -1,54 +1,41 @@ -namespace factor -{ +namespace factor { -template struct bump_allocator { - /* offset of 'here' and 'end' is hardcoded in compiler backends */ - cell here; - cell start; - cell end; - cell size; +template struct bump_allocator { + /* offset of 'here' and 'end' is hardcoded in compiler backends */ + cell here; + cell start; + cell end; + cell size; - explicit bump_allocator(cell size_, cell start_) : - here(start_), start(start_), end(start_ + size_), size(size_) {} + explicit bump_allocator(cell size_, cell start_) + : here(start_), start(start_), end(start_ + size_), size(size_) {} - bool contains_p(Block *block) - { - return ((cell)block - start) < size; - } + bool contains_p(Block* block) { return ((cell) block - start) < size; } - Block *allot(cell size) - { - cell h = here; - here = h + align(size,data_alignment); - return (Block *)h; - } + Block* allot(cell size) { + cell h = here; + here = h + align(size, data_alignment); + return (Block*)h; + } - cell occupied_space() - { - return here - start; - } + cell occupied_space() { return here - start; } - cell free_space() - { - return end - here; - } + cell free_space() { return end - here; } - cell next_object_after(cell scan) - { - cell size = ((Block *)scan)->size(); - if(scan + size < here) - return scan + size; - else - return 0; - } + cell next_object_after(cell scan) { + cell size = ((Block*)scan)->size(); + if (scan + size < here) + return scan + size; + else + return 0; + } - cell first_object() - { - if(start != here) - return start; - else - return 0; - } + cell first_object() { + if (start != here) + return start; + else + return 0; + } }; }