From d59cb7289d85bf1d0800114d8407701817b160f0 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 22 Oct 2014 00:42:54 +0200 Subject: [PATCH] Refine CFEXtensions.m --- apple/common/CFExtensions.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apple/common/CFExtensions.m b/apple/common/CFExtensions.m index fa7b001300..e99d57f952 100644 --- a/apple/common/CFExtensions.m +++ b/apple/common/CFExtensions.m @@ -18,18 +18,18 @@ #import #include "CFExtensions.h" -static CFTypeRef BRIDGING_RETAIN(id X) -{ - return X ? CFRetain((CFTypeRef)X) : NULL; -} - void CFSearchPathForDirectoriesInDomains(unsigned flags, unsigned domain_mask, unsigned expand_tilde, char *buf, size_t sizeof_buf) { - CFArrayRef array = BRIDGING_RETAIN(NSSearchPathForDirectoriesInDomains( - flags, domain_mask, (BOOL)expand_tilde)); - CFStringRef path = BRIDGING_RETAIN((id)CFArrayGetValueAtIndex(array, 0)); + CFTypeRef array_val = (CFTypeRef)NSSearchPathForDirectoriesInDomains( + flags, domain_mask, (BOOL)expand_tilde); + CFArrayRef array = array_val ? CFRetain(array_val) : NULL; + CFTypeRef path_val = (CFTypeRef)CFArrayGetValueAtIndex(array, 0); + CFStringRef path = path_val ? CFRetain(path_val) : NULL; + if (!path || !array) + return; + CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8); CFRelease(path); CFRelease(array);