]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: Refactor bump_allocator.hpp to Factor style
authorErik Charlebois <erikcharlebois@gmail.com>
Sun, 12 May 2013 01:45:44 +0000 (21:45 -0400)
committerErik Charlebois <erikcharlebois@gmail.com>
Sun, 12 May 2013 17:24:41 +0000 (13:24 -0400)
vm/bump_allocator.hpp

index bbe4df8eec18dbd997aba5c79ffd61d452f3d024..d33ce801022a39bb1e7883ba08b28449d02ef551 100644 (file)
@@ -1,54 +1,41 @@
-namespace factor
-{
-
-template<typename Block> 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_) {}
-
-       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;
-       }
-
-       cell occupied_space()
-       {
-               return here - start;
-       }
-
-       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 first_object()
-       {
-               if(start != here)
-                       return start;
-               else
-                       return 0;
-       }
+namespace factor {
+
+template <typename Block> 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_) {}
+
+  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;
+  }
+
+  cell occupied_space() { return here - start; }
+
+  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 first_object() {
+    if (start != here)
+      return start;
+    else
+      return 0;
+  }
 };
 
 }