dplug.core.vec

Defines Vec, reallocBuffer and memory functions.

Members

Functions

alignedFree
void alignedFree(void* aligned, size_t alignment)

Frees aligned memory allocated by alignedMalloc or alignedRealloc. Functionally equivalent to Visual C++ _aligned_free. Do not mix allocations with different alignment.

alignedMalloc
void* alignedMalloc(size_t size, size_t alignment)

Allocates an aligned memory chunk. Functionally equivalent to Visual C++ _aligned_malloc. Do not mix allocations with different alignment. Important: alignedMalloc(0) does not necessarily return null, and its result _has_ to be freed with alignedFree.

alignedRealloc
void* alignedRealloc(void* aligned, size_t size, size_t alignment)

Reallocates an aligned memory chunk allocated by alignedMalloc or alignedRealloc. Functionally equivalent to Visual C++ _aligned_realloc. Do not mix allocations with different alignment. Important: alignedRealloc(p, 0) does not necessarily return null, and its result _has_ to be freed with alignedFree.

isPointerAligned
bool isPointerAligned(void* p, size_t alignment)
makeVec
Vec!T makeVec(size_t initialSize = 0, int alignment = 1)
reallocBuffer
void reallocBuffer(ref T[] buffer, size_t length, int alignment = 1)

Use throughout dplug:dsp to avoid reliance on GC. Important: Size 0 is special-case to free the slice. This works a bit like alignedRealloc except with slices as input. You MUST use consistent alignement thoughout the lifetime of this buffer.

Structs

Vec
struct Vec(T)

Kind of a std::vector replacement. Grow-only array, points to a (optionally aligned) memory location. This can also work as an output range. Vec is designed to work even when uninitialized, without makeVec.

Meta

Authors

Guillaume Piolat