+/*! @function wxCFRelease
+ @abstract A CFRelease variant that checks for NULL before releasing.
+ @discussion The parameter is template not for type safety but to ensure the argument
+ is a raw pointer and not a ref holder of any type.
+*/
+template <class Type>
+inline void wxCFRelease(Type *r)
+{
+ if ( r != NULL )
+ ::CFRelease((CFTypeRef)r);
+}
+
+/*! @function wxCFRetain
+ @abstract A typesafe CFRetain variant that checks for NULL.
+*/
+template <class Type>
+inline Type* wxCFRetain(Type *r)
+{
+ // NOTE(DE): Setting r to the result of CFRetain improves efficiency on both x86 and PPC
+ // Casting r to CFTypeRef ensures we are calling the real C version defined in CFBase.h
+ // and not any possibly templated/overloaded CFRetain.
+ if ( r != NULL )
+ r = (Type*)::CFRetain((CFTypeRef)r);
+ return r;
+}
+