]> git.saurik.com Git - apple/security.git/blob - utilities/src/SecDispatchRelease.h
Security-55471.14.tar.gz
[apple/security.git] / utilities / src / SecDispatchRelease.h
1 //
2 // SecDispatchRelease.h
3 // utilities
4 //
5 // Created by Mitch Adler on 11/26/12.
6 // Copyright (c) 2012 Apple Inc. All rights reserved.
7 //
8
9
10 #ifndef _SECDISPATCHRELEASE_H_
11 #define _SECDISPATCHRELEASE_H_
12
13 #include <dispatch/dispatch.h>
14 #include <xpc/xpc.h>
15
16 #define dispatch_retain_safe(DO) { \
17 __typeof__(DO) _do = (DO); \
18 if (_do) \
19 dispatch_retain(_do); \
20 }
21
22 #define dispatch_release_safe(DO) { \
23 __typeof__(DO) _do = (DO); \
24 if (_do) \
25 dispatch_release(_do); \
26 }
27
28 #define dispatch_release_null(DO) { \
29 __typeof__(DO) _do = (DO); \
30 if (_do) { \
31 (DO) = NULL; \
32 dispatch_release(_do); \
33 } \
34 }
35
36
37 #define xpc_retain_safe(XO) { \
38 __typeof__(XO) _xo = (XO); \
39 if (_xo) \
40 xpc_retain(_xo); \
41 }
42
43 #define xpc_release_safe(XO) { \
44 __typeof__(XO) _xo = (XO); \
45 if (_xo) \
46 xpc_release(_xo); \
47 }
48
49 #define xpc_release_null(XO) { \
50 __typeof__(XO) _xo = (XO); \
51 if (_xo) { \
52 (XO) = NULL; \
53 xpc_release(_xo); \
54 } \
55 }
56
57 #endif
58