Пример #1
0
omrobjectptr_t
OMR_GC_Allocate(OMR_VMThread * omrVMThread, size_t sizeInBytes, uintptr_t flags)
{
	omrobjectptr_t heapBytes = allocHelper(omrVMThread, sizeInBytes, flags, true);
	if (NULL == heapBytes) {
		MM_GCExtensionsBase *extensions = MM_GCExtensionsBase::getExtensions(omrVMThread->_vm);
		if (NULL == extensions->getGlobalCollector()) {
			/* Lazily create the collector and try to allocate again. */
			if (OMR_ERROR_NONE == OMR_GC_InitializeCollector(omrVMThread)) {
				heapBytes = allocHelper(omrVMThread, sizeInBytes, flags, true);
			}
		}
	}
	return heapBytes;
}
Пример #2
0
const void *VFSFile::getBuf(allocator_func alloc /* = NULL */, delete_func del /* = NULL */)
{
    assert(!alloc == !del); // either both or none may be defined. Checked extra early to prevent possible errors later.

    VFS_GUARD_OPT(this);
    if(_buf)
        return _buf;

    bool op = isopen();

    if(!op && !open()) // open with default params if not open
        return NULL;

    unsigned int s = (unsigned int)size();
    _buf = allocHelper(alloc, s + 4); // a bit extra padding
    if(!_buf)
        return NULL;

    _delfunc = del;

    vfspos offs;
    if(op)
    {
        vfspos oldpos = getpos();
        seek(0);
        offs = read(_buf, s);
        seek(oldpos);
    }
    else
    {
        offs = read(_buf, s);
        close();
    }
    // Might as well be text mode reading, which means less actual bytes than size() said,
    // so this can't be done earlier.
    memset((char*)_buf + offs, 0, 4);

    return _buf;
}
Пример #3
0
omrobjectptr_t
OMR_GC_AllocateNoGC(OMR_VMThread * omrVMThread, size_t sizeInBytes, uintptr_t flags)
{
	return allocHelper(omrVMThread, sizeInBytes, flags, false);
}