void * SecCFObject::allocate(size_t size, const CFClass &cfclass) throw(std::bad_alloc) { CFTypeRef p = _CFRuntimeCreateInstance(NULL, cfclass.typeID, size + kAlignedRuntimeSize - sizeof(CFRuntimeBase), NULL); if (p == NULL) throw std::bad_alloc(); ((SecRuntimeBase*) p)->isNew = true; void *q = ((u_int8_t*) p) + kAlignedRuntimeSize; if (SECURITY_DEBUG_SEC_CREATE_ENABLED()) { const CFRuntimeClass *rtc = _CFRuntimeGetClassWithTypeID(cfclass.typeID); SECURITY_DEBUG_SEC_CREATE(q, rtc ? (char *)rtc->className : NULL, (unsigned int)cfclass.typeID); } return q; }
CFStringRef copy_description(CFTypeRef cf, CFDictionaryRef formatOptions) { CFStringRef ret; const CFRuntimeClass* cfclass; if (!cf) return NULL; cfclass = _CFRuntimeGetClassWithTypeID(CFGetTypeID(cf)); if (cfclass) { ret = CFStringCreateWithFormat(CFGetAllocator(cf), formatOptions, kCGCTypeCopyDescFormat, cfclass->className, cf); } else ret = NULL; return ret; }