예제 #1
0
static RetainPtr<CFDataRef> encodeSessionHistoryEntryData(const FrameState& frameState)
{
    static CFAllocatorRef fastMallocDeallocator;

    static std::once_flag onceFlag;
    std::call_once(onceFlag, [] {
        CFAllocatorContext context = {
            0, // version
            nullptr, // info
            nullptr, // retain
            nullptr, // release
            nullptr, // copyDescription
            nullptr, // allocate
            nullptr, // reallocate
            [](void *ptr, void *info) {
                WTF::fastFree(ptr);
            },
            nullptr, // preferredSize
        };
        fastMallocDeallocator = CFAllocatorCreate(kCFAllocatorDefault, &context);
    });

    size_t bufferSize;
    auto buffer = encodeSessionHistoryEntryData(frameState, bufferSize);

    return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer.leakPtr(), bufferSize, fastMallocDeallocator));
}
예제 #2
0
FMalloc* FMacPlatformMemory::BaseAllocator()
{
	FMalloc* Malloc = nullptr;
	
#if FORCE_ANSI_ALLOCATOR
	Malloc = new FMallocAnsi();
#elif (WITH_EDITORONLY_DATA || IS_PROGRAM) && TBB_ALLOCATOR_ALLOWED
	Malloc = new FMallocTBB();
#else
	Malloc = new FMallocBinned((uint32)(GetConstants().PageSize&MAX_uint32), 0x100000000);
#endif
	
	// Configure CoreFoundation's default allocator to use our allocation routines too.
	CFAllocatorContext AllocatorContext;
	AllocatorContext.version = 0;
	AllocatorContext.info = nullptr;
	AllocatorContext.retain = nullptr;
	AllocatorContext.release = nullptr;
	AllocatorContext.copyDescription = nullptr;
	AllocatorContext.allocate = &FMacAllocatorAllocate;
	AllocatorContext.reallocate = &FMacAllocatorReallocate;
	AllocatorContext.deallocate = &FMacAllocatorDeallocate;
	AllocatorContext.preferredSize = &FMacAllocatorPreferredSize;
	
	CFAllocatorRef Alloc = CFAllocatorCreate(kCFAllocatorDefault, &AllocatorContext);
	CFAllocatorSetDefault(Alloc);
	
	return Malloc;
}
예제 #3
0
static CFAllocatorRef createCertContextDeallocator()
{
    CFAllocatorContext allocContext = {
        0, 0, 0, 0, 0, 0, 0, deallocCertContext, 0
    };
    return CFAllocatorCreate(kCFAllocatorDefault, &allocContext);
}
예제 #4
0
    static CFAllocatorRef create()
    {
#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER)
        // Since garbage collection isn't compatible with custom allocators, don't use this at all when garbage collection is active.
        if (objc_collectingEnabled())
            return 0;
#endif
        CFAllocatorContext context = { 0, 0, retain, release, copyDescription, allocate, reallocate, deallocate, preferredSize };
        return CFAllocatorCreate(0, &context);
    }
예제 #5
0
static CFAllocatorRef createShareableResourceDeallocator(ShareableResource* resource)
{
    CFAllocatorContext context = { 0,
        resource,
        NULL, // retain
        NULL, // release
        NULL, // copyDescription
        NULL, // allocate
        NULL, // reallocate
        shareableResourceDeallocate,
        NULL, // preferredSize
    };

    return CFAllocatorCreate(kCFAllocatorDefault, &context);
}
예제 #6
0
static CFAllocatorRef createShareableResourceDeallocator(PassRefPtr<ShareableResource> resource)
{
    CFAllocatorContext context = { 0,
        resource.leakRef(),
        NULL, // retain
        NULL, // release
        NULL, // copyDescription
        NULL, // allocate
        NULL, // reallocate
        shareableResourceDeallocate,
        NULL,
    };

    return CFAllocatorCreate(kCFAllocatorDefault, &context);
}
예제 #7
0
 static CFAllocatorRef create()
 {
     ASSERT(!garbageCollectionEnabled());
     CFAllocatorContext context = { 0, 0, retain, release, copyDescription, allocate, reallocate, deallocate, preferredSize };
     return CFAllocatorCreate(0, &context);
 }
예제 #8
0
static CFAllocatorRef create()
{
    CFAllocatorContext context = { 0, 0, retain, release, copyDescription, allocate, reallocate, deallocate, preferredSize };
    return CFAllocatorCreate(0, &context);
}