From 51fc494d71562757eb5a5c895346dbae63acc067 Mon Sep 17 00:00:00 2001 From: Shane Pearman Date: Fri, 15 Sep 2017 05:42:29 -0700 Subject: [PATCH] Assert size_of type parameter greater than zero --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index eb889ae..33198c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,8 +316,12 @@ impl Drop for Buffer { /// If the requested queue size is larger than available memory (e.g. /// `capacity.next_power_of_two() * size_of::() > available memory` ), this function will abort /// with an OOM panic. +/// +/// If the type parameter is a zero-size type. pub fn make(capacity: usize) -> (Producer, Consumer) { + assert!(0 < std::mem::size_of::(), "zero-size types are not supported"); + let ptr = unsafe { allocate_buffer(capacity) }; let arc = Arc::new(Buffer{