# Interface VulkanTemporaryAllocatorType

All Known Implementing Classes:
  `VulkanLWJGLTemporaryAllocator`

public interface VulkanTemporaryAllocatorType
An allocator for temporary, aligned memory. The API is designed such that it should be very difficult, short of deliberate sabotage, to leak memory or use memory after it has been freed.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `VulkanTemporaryAllocatorType.ByteBufferMemoryReceiverType<T, E extends Exception>`
  A receiver of allocated memory.
  `static interface`
  `VulkanTemporaryAllocatorType.RawMemoryReceiverType<T, E extends Exception>`
  A receiver of allocated memory.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T, E extends Exception>
  T`
  `withAllocation(long size, long alignment, VulkanTemporaryAllocatorType.RawMemoryReceiverType<T,E> receiver)`
  Allocate `size` octets of memory, aligned to `alignment`, pass it to `receiver`, then unconditionally deallocate the memory before returning the value of `T` returned by `receiver`.
  `<T, E extends Exception>
  T`
  `withAllocationBuffer(long size, long alignment, VulkanTemporaryAllocatorType.ByteBufferMemoryReceiverType<T,E> receiver)`
  Allocate `size` octets of memory, aligned to `alignment`, pass it to `receiver`, then unconditionally deallocate the memory before returning the value of `T` returned by `receiver`.
  `<T, E extends Exception>
  T`
  `withAllocationBufferInitialized(byte[] data, long alignment, VulkanTemporaryAllocatorType.ByteBufferMemoryReceiverType<T,E> receiver)`
  Allocate `data.length` octets of memory, aligned to `alignment`, initialize it with the contents of `data`, pass it to `receiver`, then unconditionally deallocate the memory before returning the value of `T` returned by `receiver`.

- ## Method Details

  - ### withAllocation

    <T, E extends Exception> T withAllocation(long size, long alignment, VulkanTemporaryAllocatorType.RawMemoryReceiverType<T,E> receiver) throws VulkanException, E
    Allocate `size` octets of memory, aligned to `alignment`, pass it to `receiver`, then unconditionally deallocate the memory before returning the value of `T` returned by `receiver`.
    Type Parameters:
      `T` - The type of returned values
      `E` - The type of raised exceptions
    Parameters:
      `size` - The size of the memory
      `alignment` - The alignment of the memory
      `receiver` - The receiver of the allocated memory
    Returns:
      The value returned by `receiver`
    Throws:
      `VulkanException` - If `receiver` raises `VulkanException`
      `E` - If `receiver` raises `E`

  - ### withAllocationBuffer

    <T, E extends Exception> T withAllocationBuffer(long size, long alignment, VulkanTemporaryAllocatorType.ByteBufferMemoryReceiverType<T,E> receiver) throws VulkanException, E
    Allocate `size` octets of memory, aligned to `alignment`, pass it to `receiver`, then unconditionally deallocate the memory before returning the value of `T` returned by `receiver`.
    Type Parameters:
      `T` - The type of returned values
      `E` - The type of raised exceptions
    Parameters:
      `size` - The size of the memory
      `alignment` - The alignment of the memory
      `receiver` - The receiver of the allocated memory
    Returns:
      The value returned by `receiver`
    Throws:
      `VulkanException` - If `receiver` raises `VulkanException`
      `E` - If `receiver` raises `E`

  - ### withAllocationBufferInitialized

    <T, E extends Exception> T withAllocationBufferInitialized(byte[] data, long alignment, VulkanTemporaryAllocatorType.ByteBufferMemoryReceiverType<T,E> receiver) throws VulkanException, E
    Allocate `data.length` octets of memory, aligned to `alignment`, initialize it with the contents of `data`, pass it to `receiver`, then unconditionally deallocate the memory before returning the value of `T` returned by `receiver`.
    Type Parameters:
      `T` - The type of returned values
      `E` - The type of raised exceptions
    Parameters:
      `data` - The initial contents of the memory
      `alignment` - The alignment of the memory
      `receiver` - The receiver of the allocated memory
    Returns:
      The value returned by `receiver`
    Throws:
      `VulkanException` - If `receiver` raises `VulkanException`
      `E` - If `receiver` raises `E`