/* Note that there are two entry points for creating CFErrors. * This one does it with a presupplied userInfo dictionary. */ CFErrorRef CFErrorCreate(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, CFDictionaryRef userInfo) { CF_VALIDATE_OBJECT_ARG(CF, domain, CFStringGetTypeID()); if (userInfo) { CF_VALIDATE_OBJECT_ARG(CF, userInfo, CFDictionaryGetTypeID()); } CFErrorRef err = (CFErrorRef)_CFRuntimeCreateInstance( allocator, __kCFErrorTypeID, sizeof(struct __CFError) - sizeof(CFRuntimeBase), NULL); if (!err) { return NULL; } err->domain = CFStringCreateCopy(allocator, domain); err->code = code; err->userInfo = userInfo ? CFDictionaryCreateCopy(allocator, userInfo) : _CFErrorCreateEmptyDictionary(allocator); return err; }
/* Note that there are two entry points for creating CFErrors. This one does it with a presupplied userInfo dictionary. */ CFErrorRef CFErrorCreate(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, CFDictionaryRef userInfo) { __CFGenericValidateType(domain, CFStringGetTypeID()); if (userInfo) __CFGenericValidateType(userInfo, CFDictionaryGetTypeID()); CFErrorRef err = (CFErrorRef)_CFRuntimeCreateInstance(allocator, __kCFErrorTypeID, sizeof(struct __CFError) - sizeof(CFRuntimeBase), NULL); if (NULL == err) return NULL; err->domain = CFStringCreateCopy(allocator, domain); err->code = code; err->userInfo = userInfo ? CFDictionaryCreateCopy(allocator, userInfo) : _CFErrorCreateEmptyDictionary(allocator); return err; }
/* This accessor never returns NULL. For usage inside this file, consider __CFErrorGetUserInfo(). */ CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) { CFDictionaryRef userInfo = _CFErrorGetUserInfo(err); return userInfo ? (CFDictionaryRef)CFRetain(userInfo) : _CFErrorCreateEmptyDictionary(CFGetAllocator(err)); }