Don't forget to CFRelease this!
(self)
| 21 | impl Config { |
| 22 | /// Don't forget to CFRelease this! |
| 23 | pub fn build(self) -> CFDictionaryRef { |
| 24 | unsafe { |
| 25 | let throttle = CFNumberCreate( |
| 26 | ptr::null_mut(), |
| 27 | CFNumberType::Float64, |
| 28 | &self.throttle as *const _ as *const c_void, |
| 29 | ); |
| 30 | let queue_length = CFNumberCreate( |
| 31 | ptr::null_mut(), |
| 32 | CFNumberType::SInt8, |
| 33 | &self.queue_length as *const _ as *const c_void, |
| 34 | ); |
| 35 | |
| 36 | let keys: [CFStringRef; 4] = [ |
| 37 | kCGDisplayStreamShowCursor, |
| 38 | kCGDisplayStreamPreserveAspectRatio, |
| 39 | kCGDisplayStreamMinimumFrameTime, |
| 40 | kCGDisplayStreamQueueDepth, |
| 41 | ]; |
| 42 | let values: [*mut c_void; 4] = [ |
| 43 | cfbool(self.cursor), |
| 44 | cfbool(self.letterbox), |
| 45 | throttle, |
| 46 | queue_length, |
| 47 | ]; |
| 48 | |
| 49 | let res = CFDictionaryCreate( |
| 50 | ptr::null_mut(), |
| 51 | keys.as_ptr(), |
| 52 | values.as_ptr(), |
| 53 | 4, |
| 54 | &kCFTypeDictionaryKeyCallBacks, |
| 55 | &kCFTypeDictionaryValueCallBacks, |
| 56 | ); |
| 57 | |
| 58 | CFRelease(throttle); |
| 59 | CFRelease(queue_length); |
| 60 | |
| 61 | res |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | impl Default for Config { |
no test coverage detected