Skip to content

Commit

Permalink
Assert that the alignment of Shared is appropriate (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog authored and seanmonstar committed Jan 23, 2020
1 parent ab028eb commit 788cb15
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,12 @@ struct Shared {
ref_cnt: AtomicUsize,
}

// Assert that the alignment of `Shared` is divisible by 2.
// This is a necessary invariant since we depend on allocating `Shared` a
// shared object to implicitly carry the `KIND_ARC` flag in its pointer.
// This flag is set when the LSB is 0.
const _: [(); 0 - mem::align_of::<Shared>() % 2] = []; // Assert that the alignment of `Shared` is divisible by 2.

static SHARED_VTABLE: Vtable = Vtable {
clone: shared_clone,
drop: shared_drop,
Expand Down

0 comments on commit 788cb15

Please sign in to comment.