1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
18 dtor: Option<unsafe extern fn(*mut u8)>,
22 pub unsafe fn create(dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
23 Box::into_raw(Box::new(Allocated {
24 value: ptr::null_mut(),
30 pub unsafe fn set(key: Key, value: *mut u8) {
31 (*(key as *mut Allocated)).value = value;
35 pub unsafe fn get(key: Key) -> *mut u8 {
36 (*(key as *mut Allocated)).value
40 pub unsafe fn destroy(key: Key) {
41 let key = Box::from_raw(key as *mut Allocated);
42 if let Some(f) = key.dtor {
48 pub fn requires_synchronized_create() -> bool {