Prechádzať zdrojové kódy

Alignment assertions

ticki 9 rokov pred
rodič
commit
537920f98d
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  1. 3 0
      src/bookkeeper.rs

+ 3 - 0
src/bookkeeper.rs

@@ -207,6 +207,7 @@ impl BlockList {
 
             // Check consistency.
             self.check();
+            debug_assert!(*res as usize % align == 0, "Alignment in `alloc` failed.");
 
             res
         } else {
@@ -272,6 +273,7 @@ impl BlockList {
 
         // Check consistency.
         self.check();
+        debug_assert!(*res.ptr as usize % align == 0, "Alignment in `alloc_fresh` failed.");
 
         res.ptr
     }
@@ -356,6 +358,7 @@ impl BlockList {
 
             // Check consistency.
             self.check();
+            debug_assert!(*ptr as usize % align == 0, "Alignment in `realloc` failed.");
 
             ptr
         }