22typedef VL_MEMORY_SIZE_T vl_memsize_t;
30#define VL_KB(x) ((vl_memsize_t)(x) << 10)
39#define VL_MB(x) ((vl_memsize_t)(x) << 20)
42#ifndef VL_DEFAULT_MEMORY_SIZE
46#define VL_DEFAULT_MEMORY_SIZE VL_KB(1)
49#ifndef VL_DEFAULT_MEMORY_ALIGN
52#define VL_ALIGNOF(T) __alignof(T)
54#define VL_ALIGNOF(T) __alignof__(T)
60#define VL_DEFAULT_MEMORY_ALIGN VL_ALIGNOF(vl_ularge_t)
63#ifndef VL_MEMORY_PAD_UP
75#define VL_MEMORY_PAD_UP(len, pad) (((len) + (pad) - 1) & ~((pad) - 1))
86#define VL_ALIGN_HINT(x) __declspec(align(x))
87#elif defined(__GNUC__) || defined(__clang__)
88#define VL_ALIGN_HINT(x) __attribute__((aligned(x)))
90#define VL_ALIGN_HINT(x)
91#warning VL_ALIGN_HINT failed to resolve. Structure alignment is not guaranteed.
235#define vlMemAllocType(element_type) ((element_type*)vlMemAllocAligned(sizeof(element_type), VL_ALIGNOF(element_type)))
271#define vlMemAllocTypeArray(element_type, count) \
272 ((element_type*)vlMemAllocAligned(sizeof(element_type) * (count), VL_ALIGNOF(element_type)))
328#elif defined(__GNUC__) || defined(__clang__)
331#error Failed to resolve stack allocation method.
436#define vlMemAllocStackType(element_type) \
437 ((element_type*)vlMemAllocStackAligned(sizeof(element_type), VL_ALIGNOF(element_type)))
478#define vlMemAllocStackTypeArray(element_type, count) \
479 ((element_type*)vlMemAllocStackAligned((count) * sizeof(element_type), VL_ALIGNOF(element_type)))
572VL_API
void vlMemSort(
void* buffer, vl_memsize_t elementSize,
vl_dsidx_t numElements, vl_compare_function comparator);
600 vl_memsize_t elementSize,
vl_dsidx_t numElements);
672#define vlMemReverse(src, numBytes) vlMemReverseSubArraysStride(src, 1, numBytes, 1)
675#ifndef vlMemReverseSubArrays
696#define vlMemReverseSubArrays(src, elementSize, numElements) \
697 vlMemReverseSubArraysStride(src, elementSize, elementSize, numElements)
vl_transient * vlMemAllocStack(vl_memsize_t allocSize)
Allocate memory on the stack (automatic storage).
Definition vl_memory.h:324
VL_API void vlMemFree(vl_memory *mem)
Frees the specified block of memory.
Definition vl_memory.c:272
VL_API vl_memory * vlMemRealloc(vl_memory *mem, vl_memsize_t allocSize)
Reallocates the specified block of memory to hold the specified total number of bytes.
Definition vl_memory.c:79
VL_API vl_memory * vlMemAlloc(vl_memsize_t allocSize)
Attempts to allocate a block of memory.
Definition vl_memory.c:42
VL_API void vlMemSort(void *buffer, vl_memsize_t elementSize, vl_dsidx_t numElements, vl_compare_function comparator)
Sorts the specified buffer in-place according to the specified element and comparator function.
Definition vl_memory.c:197
VL_API vl_memory * vlMemClone(vl_memory *mem)
Clones the specified block of memory, returning a pointer to its new clone.
Definition vl_memory.c:118
VL_API void vlMemCopyStride(const void *src, vl_dsoffs_t srcStride, void *dest, vl_dsoffs_t dstStride, vl_memsize_t elementSize, vl_dsidx_t numElements)
Copies data from one buffer to another, with a stride applied to both.
Definition vl_memory.c:214
VL_API vl_memsize_t vlMemSize(vl_memory *mem)
Returns the size (in total number of bytes) of the specified block of vl_memory.
Definition vl_memory.c:265
VL_MEMORY_T vl_memory
Definition vl_memory.h:108
VL_MEMORY_T vl_transient
Definition vl_memory.h:118
VL_API void vlMemReverseSubArraysStride(void *src, vl_dsoffs_t srcStride, vl_memsize_t elementSize, vl_dsidx_t numElements)
Reverses the bytes in a series of elements of a defined length and stride between them.
Definition vl_memory.c:234
VL_API vl_memory * vlMemAllocAligned(vl_memsize_t allocSize, vl_uint_t align)
Allocates a block of memory with an alignment.
Definition vl_memory.c:56
VL_API vl_uint_t vlMemAlignment(vl_memory *mem)
Returns the alignment of the specified block of memory.
Definition vl_memory.c:258
vl_transient * vlMemAllocStackAligned(vl_memsize_t allocSize, vl_uint16_t align)
Allocate aligned memory on the stack (automatic storage).
Definition vl_memory.h:390
VL_UPTR_T vl_uintptr_t
Unsigned integer type suitable for expressing memory addresses.
Definition vl_numtypes.h:163
VL_UINT_T vl_uint_t
Standard unsigned integer type.
Definition vl_numtypes.h:158
VL_STRUCTURE_INDEX_T vl_dsidx_t
Index type for data structures.
Definition vl_numtypes.h:75
VL_STRUCTURE_OFFSET_T vl_dsoffs_t
Byte offset type for data structures.
Definition vl_numtypes.h:70