Debian Codegraph @

third_party/rust/coreaudio-sys-utils/src/cf_mutable_dict.rs

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