org.lwjgl.vulkan.VkReallocationFunctionI Maven / Gradle / Ivy
Show all versions of lwjgl-vulkan Show documentation
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.vulkan;
import org.lwjgl.system.*;
import org.lwjgl.system.libffi.*;
import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.libffi.LibFFI.*;
/**
* Application-defined memory reallocation function.
*
* C Specification
*
* The type of {@code pfnReallocation} is:
*
*
* typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)(
* void* pUserData,
* void* pOriginal,
* size_t size,
* size_t alignment,
* VkSystemAllocationScope allocationScope);
*
* Description
*
* {@code pfnReallocation} must return an allocation with enough space for {@code size} bytes, and the contents of the original allocation from bytes zero to min(original size, new size) - 1
must be preserved in the returned allocation. If {@code size} is larger than the old size, the contents of the additional space are undefined. If satisfying these requirements involves creating a new allocation, then the old allocation should be freed.
*
* If {@code pOriginal} is {@code NULL}, then {@code pfnReallocation} must behave equivalently to a call to {@link VkAllocationFunction} with the same parameter values (without {@code pOriginal}).
*
* If {@code size} is zero, then {@code pfnReallocation} must behave equivalently to a call to {@link VkFreeFunction} with the same {@code pUserData} parameter value, and {@code pMemory} equal to {@code pOriginal}.
*
* If {@code pOriginal} is non-{@code NULL}, the implementation must ensure that {@code alignment} is equal to the {@code alignment} used to originally allocate {@code pOriginal}.
*
* If this function fails and {@code pOriginal} is non-{@code NULL} the application must not free the old allocation.
*
* {@code pfnReallocation} must follow the same rules for return values as {@code PFN_vkAllocationFunction}.
*
* See Also
*
* {@link VkAllocationCallbacks}
*/
@FunctionalInterface
@NativeType("PFN_vkReallocationFunction")
public interface VkReallocationFunctionI extends CallbackI {
FFICIF CIF = apiCreateCIF(
apiStdcall(),
ffi_type_pointer,
ffi_type_pointer, ffi_type_pointer, ffi_type_pointer, ffi_type_pointer, ffi_type_uint32
);
@Override
default FFICIF getCallInterface() { return CIF; }
@Override
default void callback(long ret, long args) {
long __result = invoke(
memGetAddress(memGetAddress(args)),
memGetAddress(memGetAddress(args + POINTER_SIZE)),
memGetAddress(memGetAddress(args + 2 * POINTER_SIZE)),
memGetAddress(memGetAddress(args + 3 * POINTER_SIZE)),
memGetInt(memGetAddress(args + 4 * POINTER_SIZE))
);
apiClosureRetP(ret, __result);
}
/**
* Application-defined memory reallocation function.
*
* @param pUserData the value specified for {@link VkAllocationCallbacks}{@code ::pUserData} in the allocator specified by the application.
* @param pOriginal must be either {@code NULL} or a pointer previously returned by {@code pfnReallocation} or {@code pfnAllocation} of a compatible allocator.
* @param size the size in bytes of the requested allocation.
* @param alignment the requested alignment of the allocation in bytes and must be a power of two.
* @param allocationScope a {@code VkSystemAllocationScope} value specifying the allocation scope of the lifetime of the allocation, as described here.
*/
@NativeType("void *") long invoke(@NativeType("void *") long pUserData, @NativeType("void *") long pOriginal, @NativeType("size_t") long size, @NativeType("size_t") long alignment, @NativeType("VkSystemAllocationScope") int allocationScope);
}