]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/bump_allocator.hpp
webapps: better style
[factor.git] / vm / bump_allocator.hpp
index dc3339f2eea60a8ee236fef0d1612a046b3c4aae..28aa527fd49104f8faff3f0bcb7bccc84ab9fabd 100644 (file)
@@ -1,7 +1,7 @@
 namespace factor {
 
 struct bump_allocator {
-  /* offset of 'here' and 'end' is hardcoded in compiler backends */
+  // offset of 'here' and 'end' is hardcoded in compiler backends
   cell here;
   cell start;
   cell end;
@@ -10,7 +10,9 @@ struct bump_allocator {
   bump_allocator(cell size, cell start)
       : here(start), start(start), end(start + size), size(size) {}
 
-  bool contains_p(object* obj) { return ((cell)obj - start) < size; }
+  bool contains_p(object* obj) {
+    return (cell)obj >= start && (cell)obj < end;
+  }
 
   object* allot(cell size) {
     cell h = here;
@@ -25,9 +27,9 @@ struct bump_allocator {
   void flush() {
     here = start;
 #ifdef FACTOR_DEBUG
-    /* In case of bugs, there may be bogus references pointing to the
-       memory space after the gc has run. Filling it with a pattern
-       makes accesses to such shadow data fail hard. */
+    // In case of bugs, there may be bogus references pointing to the
+    // memory space after the gc has run. Filling it with a pattern
+    // makes accesses to such shadow data fail hard.
     memset_cell((void*)start, 0xbaadbaad, size);
 #endif
   }