Bug 1929171 - Make helper_fission_setResolution.html work on hi-DPI environments...
[gecko.git] / third_party / rust / coreaudio-sys-utils / src / cf_mutable_dict.rs
blob86f585fa697ace8963a7ffe8ec96f16c98b325d7
1 use coreaudio_sys::*;
2 use std::os::raw::c_void;
4 pub struct CFMutableDictRef(CFMutableDictionaryRef);
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     }
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     }
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     }