joka.memory
The memory module provides functions for dealing with memory and various general-purpose containers. List, BufferList, and FixedList are the "basic" containers. Most other containers can accept one of those to adjust their allocation strategy.
Types 21
Replaces the global memory context for the current scope with the given allocator.
MemoryContext _previousMemoryContextA dynamic string of chars backed by external memory.
A dynamic array.
isBasicContainer isBufferContainer hasFixedCapacityT[] itemsSz capacityMemoryContext capturebool canIgnoreLeakbool appendSource(IStr file = __FILE__, Sz line = __LINE__, const(T)[] args = []...) @trusted @safe nothrowthis(MemoryContext capture, const(T)[] args...)this(ref GrowingArena arena, const(T)[] args...)this(const(T)[] args...)A dynamic array that uses external memory provided at runtime.
bool growCapacity(C)(ref C arena)bool resizeCapacity(C)(ref C arena, Sz newCapacity) @trustedbool appendSource(IStr file = __FILE__, Sz line = __LINE__, const(T)[] args = []...) @trusted @safe nothrow @nogcthis(T[] data, const(T)[] args...)A dynamic array allocated on the stack.
bool appendSource(IStr file = __FILE__, Sz line = __LINE__, const(T)[] args = []...) @trusted @safe nothrow @nogcthis(const(T)[] args...)An item of a sparse array.
Item valuebool flagA dynamic sparse array.
bool appendSource(IStr file = __FILE__, Sz line = __LINE__, const(T)[] args = []...) @trusted @safe nothrowthis(MemoryContext capture, const(T)[] args...)this(ref GrowingArena arena, const(T)[] args...)this(const(T)[] args...)A dynamic generational array.
isBasicContainer isBufferContainer hasFixedCapacityD dataG generationsA dynamic bit array.
isBasicContainer isBufferContainer hasFixedCapacityD bucketsSz length zero one bucketCapacity bucketIndexMask bucketShiftAmountbool appendSource(IStr file = __FILE__, Sz line = __LINE__, const(bool)[] args = []...) @safe nothrowThe common bit array type.
A dynamic 2D array.
void resizeBlank(Sz newRowCount, Sz newColCount, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowA static arena allocator.
ubyte * dataSz capacitySz offsetSz checkpointOffsetSz previousOffsetvoid * lastPtrArena * nextvoid * malloc(Sz alignment, Sz size, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrow @nogcvoid * realloc(Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrow @nogcT[] makeSlice(T)(Sz length, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrow @nogcT[] makeSlice(T)(const(T)[] values, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrow @nogcT[] resizeSlice(T)(T * values, Sz oldLength, Sz newLength, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrow @nogcA dynamic arena allocator.
void * realloc(Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrowT[] makeSlice(T)(Sz length, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrowT[] resizeSlice(T)(T * values, Sz oldLength, Sz newLength, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrowvoid * realloc(Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrowT[] makeSlice(T)(Sz length, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrowT[] resizeSlice(T)(T * values, Sz oldLength, Sz newLength, IStr file = __FILE__, Sz line = __LINE__) @trusted nothrowthis(ref T data)Functions 64
ScopedMemoryContext ScopedDefaultMemoryContext() @safe nothrow @nogcReplaces the global memory context for the current scope with the default allocator.void * jokaSystemReallocWrapper(void * allocatorState, Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file, Sz line) @system nothrowA realloc wrapper that uses the system allocator.void * jokaMalloc(Sz size, IStr file = __FILE__, Sz line = __LINE__) @system nothrowAllocates a block of memory.void * jokaRealloc(void * ptr, Sz size, Sz oldSize = 0, IStr file = __FILE__, Sz line = __LINE__) @system nothrowReallocates a block of memory.void jokaFree(void * ptr, Sz oldSize = 0, IStr file = __FILE__, Sz line = __LINE__) @system nothrowFrees a block of memory.T * jokaMakeBlank(T)(IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates memory for a value without initializing it.T * jokaMakeBlank(T)(MemoryContext context, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates memory for a value without initializing it.T * jokaMake(T)(IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates memory for a value and initializes it.T * jokaMake(T)(MemoryContext context, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates memory for a value and initializes it.T * jokaMake(T)(const(T) value, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates memory for a value and initializes it.T * jokaMake(T)(MemoryContext context, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates memory for a value and initializes it.T[] jokaMakeSliceBlank(T)(Sz length, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice without initializing its elements.T[] jokaMakeSliceBlank(T)(MemoryContext context, Sz length, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice without initializing its elements.T[] jokaMakeSlice(T)(Sz length, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice and initializes its elements.T[] jokaMakeSlice(T)(MemoryContext context, Sz length, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice and initializes its elements.T[] jokaMakeSlice(T)(Sz length, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice and initializes its elements.T[] jokaMakeSlice(T)(MemoryContext context, Sz length, const(T) value, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice and initializes its elements.T[] jokaMakeSlice(T)(const(T)[] values, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice and initializes its elements.T[] jokaMakeSlice(T)(MemoryContext context, const(T)[] values, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedAllocates a slice and initializes its elements.T[] jokaResizeSlice(T)(T * values, Sz length, Sz oldLength = 0, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedResizes a slice, with the previous pointer getting freed.T[] jokaResizeSlice(T)(MemoryContext context, T * values, Sz length, Sz oldLength = 0, IStr file = __FILE__, Sz line = __LINE__) @system nothrow @trustedResizes a slice, with the previous pointer getting freed.T jokaMakeJointBlank(T)(Sz * outTotalBytes, Sz[] lengths...) if (is(T == struct)) @system nothrow @trustedAllocates a struct's slice fields in a single contiguous block without initializing them. Free the entire block by freeing the first field's pointer.T jokaMakeJointBlank(T)(MemoryContext context, Sz * outTotalBytes, Sz[] lengths...) if (is(T == struct)) @system nothrow @trustedAllocates a struct's slice fields in a single contiguous block without initializing them. Free the entire block by freeing the first field's pointer.T jokaMakeJoint(T)(Sz[] lengths...) if (is(T == struct)) @system nothrow @trustedAllocates a struct's slice fields in a single contiguous block and initializes them to zero. Free the entire block by freeing the first field's pointer.T jokaMakeJoint(T)(MemoryContext context, Sz[] lengths...) if (is(T == struct)) @system nothrow @trustedAllocates a struct's slice fields in a single contiguous block and initializes them to zero. Free the entire block by freeing the first field's pointer.void * nullAllocatorReallocWrapper(void * allocatorState, Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file, Sz line) @system nothrow @trusted @nogcA realloc wrapper that always returns null.void jokaRestoreNullAllocatorSetup(ref MemoryContext context) @system nothrow @trusted @nogcConfigures a memory context to use the null allocator.void jokaRestoreDefaultAllocatorSetup(ref MemoryContext context) @system nothrow @trusted @nogcConfigures a memory context to use the default allocator.void jokaEnsureCapture(ref MemoryContext capture) @system nothrow @trusted @nogcSets a memory context to the global context if it has no realloc function.auto ignoreLeak(T)(T ptr) @system nothrow @trusted @nogcMarks an allocation as ignored by the memory tracker.Sz beginAllocationGroup(IStr group) @system nothrow @trustedBegins a new allocation group for the memory tracker and returns the current group depth.Sz endAllocationGroup() @system nothrow @trusted @nogcEnds the current allocation group for the memory tracker and returns the current group depth.IStr memoryTrackingInfo(IStr pathFilter = "", bool canShowEmpty = false) @trusted nothrowReturns a summary of memory leaks and invalid frees detected by the memory tracker.void * arenaAllocatorReallocWrapper(void * allocatorState, Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file, Sz line) @trusted @nogc @safe nothrowvoid * growingArenaAllocatorReallocWrapper(void * allocatorState, Sz alignment, void * oldPtr, Sz oldSize, Sz newSize, IStr file, Sz line) @trusted @safe nothrowSz findListCapacityFastAndAssumeOneAddedItemInLength(Sz length, Sz currentCapacity = 0) @trusted @nogc @safe nothrowIStr fmtIntoListWithStrs(S = LStr)(ref S list, bool canAppend, IStr fmtStr, IStr[] args...) @safe nothrowFormats a string using a list and returns the resulting formatted string. The list is cleared before writing if `canAppend` is false. For details on formatting behavior, see the `fmtIntoBufferWithS...IStr fmtIntoList(S = LStr, A...)(ref S list, bool canAppend, IStr fmtStr, A args) @safe nothrowFormats a string using a list and returns the resulting formatted string. The list is cleared before writing if `canAppend` is false. For details on formatting behavior, see the `fmtIntoBufferWithS...IStr fmtIntoList(S = LStr, A...)(ref S list, bool canAppend, InterpolationHeader header, A args, InterpolationFooter footer) @safe nothrowFormats a string using a list and returns the resulting formatted string. The list is cleared before writing if `canAppend` is false. For details on formatting behavior, see the `fmtIntoBufferWithS...IStr sprintf(S = LStr, A...)(ref S buffer, IStr fmtStr, A args) @safe nothrowPrints formatted text to the given buffer. For details on formatting, see the `fmtIntoBuffer` function.IStr sprintf(S = LStr, A...)(ref S buffer, InterpolationHeader header, A args, InterpolationFooter footer) @safe nothrowPrints formatted text to the given buffer. For details on formatting, see the `fmtIntoBuffer` function.IStr sprintfln(S = LStr, A...)(ref S buffer, IStr fmtStr, A args) @safe nothrowPrints formatted text with a new line at the end to the given buffer. For details on formatting, see the `fmtIntoBuffer` function.IStr sprintfln(S = LStr, A...)(ref S buffer, InterpolationHeader header, A args, InterpolationFooter footer) @safe nothrowPrints formatted text with a new line at the end to the given buffer. For details on formatting, see the `fmtIntoBuffer` function.void sprintln(S = LStr, A...)(ref S buffer, A args) @safe nothrowPrints text with a new line at the end to the given buffer.void freeOnlyItems(T)(ref T container, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowFrees only the items within the container without freeing the container itself. Calls `free` on each item, passing `file` and `line` if supported.void freeWithItems(T)(ref T container, IStr file = __FILE__, Sz line = __LINE__) @safe nothrowFrees all items within the container and then frees the container itself. Equivalent to calling `freeOnlyItems` followed by `free` on the container.Variables 3
MemoryContext __memoryContextdefaultJokaMemoryAlignment = 16defaultListCapacity = 8The default list capacity. It is also the smallest list capacity.