1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
//! Dynamic allocation/deallocation on heap. use super::{Node,Link}; use rust::*; pub type Phantom<T> = PhantomData<Box<Node<T>>>; pub(crate) fn make_node<T>( data: T ) -> *mut Node<T> { let mut node = Box::new( Node { link: Link { next : null_mut(), child : null_mut(), }, data, } ); node.reset_sib(); Box::into_raw( node ) } pub(crate) fn drop_node<T>( node: *mut Node<T> ) { unsafe{ Box::from_raw( node ); }}