blob: 86f585fa697ace8963a7ffe8ec96f16c98b325d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use coreaudio_sys::*;
use std::os::raw::c_void;
pub struct CFMutableDictRef(CFMutableDictionaryRef);
impl CFMutableDictRef {
pub fn add_value<K, V>(&self, key: *const K, value: *const V) {
assert!(!self.0.is_null());
unsafe {
CFDictionaryAddValue(self.0, key as *const c_void, value as *const c_void);
}
}
}
impl Default for CFMutableDictRef {
fn default() -> Self {
let dict = unsafe {
CFDictionaryCreateMutable(
kCFAllocatorDefault,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks,
)
};
assert!(!dict.is_null());
Self(dict)
}
}
impl Drop for CFMutableDictRef {
fn drop(&mut self) {
assert!(!self.0.is_null());
unsafe {
CFRelease(self.0 as *const c_void);
}
}
}
|