dplug.core.nogc

Various @nogc alternatives. This file includes parts of std.process, std.random, std.uuid.

Members

Aliases

nogcComparisonFunction
alias nogcComparisonFunction(T) = int delegate(in T a, in T b) nothrow @(nogc)

Must return -1 if a < b 0 if a == b 1 if a > b

Functions

assumeZeroTerminated
const(char)* assumeZeroTerminated(const(char)[] input)

Semantic function to check that a D string implicitely conveys a termination byte after the slice. (typically those comes from string literals or stringDup/stringIDup)

debugBreak
void debugBreak()

Inserts a breakpoint instruction. useful to trigger the debugger.

destroyFree
void destroyFree(T p)

Destroys and frees a class object created with mallocEmplace.

destroyFree
void destroyFree(T p)

Destroys and frees an interface object created with mallocEmplace.

destroyFree
void destroyFree(T* p)

Destroys and frees a non-class object created with mallocEmplace.

freeSlice
void freeSlice(const(T)[] slice)

Frees a slice allocated with mallocSlice.

mallocDup
T[] mallocDup(const(T)[] slice)

Duplicates a slice with malloc. Equivalent to .dup Has to be cleaned-up with free().

mallocEmplace
auto mallocEmplace(Args args)

Allocates and construct a struct or class object. Returns: Newly allocated object.

mallocIDup
immutable(T)[] mallocIDup(const(T)[] slice)

Duplicates a slice with malloc. Equivalent to .idup Has to be cleaned-up with free().

mallocNew
auto mallocNew(Args args)

Allocates and construct a struct or class object. Returns: Newly allocated object.

mallocSlice
T[] mallocSlice(size_t count)

Allocates a slice with malloc.

mallocSliceNoInit
T[] mallocSliceNoInit(size_t count)

Allocates a slice with malloc, but does not initialize the content.

mergeSort
void mergeSort(T[] inoutElements, T[] scratchBuffer, nogcComparisonFunction!T comparison)

Stable merge sort, using a temporary array. Array A[] has the items to sort. Array B[] is a work array. grailSort is approx. 30% slower but doesn't need a scratchBuffer.

quicksort
void quicksort(T[] array, nogcComparisonFunction!T comparison)

@nogc quicksort From the excellent: http://codereview.stackexchange.com/a/77788

stringDup
char[] stringDup(const(char)* cstr)

Duplicates a zero-terminated string with malloc, return a char[]. Equivalent to .dup Has to be cleaned-up with free(). Note: The zero-terminating byte is preserved. This allow to have a string which also can be converted to a C string with .ptr. However the zero byte is not included in slice length.

stringIDup
string stringIDup(const(char)* cstr)

Duplicates a zero-terminated string with malloc, return a string. Equivalent to .idup Has to be cleaned-up with free(). Note: The zero-terminating byte is preserved. This allow to have a string which also can be converted to a C string with .ptr. However the zero byte is not included in slice length.

unrecoverableError
void unrecoverableError()

To call for something that should never happen, but we still want to make a "best effort" at runtime even if it can be meaningless. MAYDO: change that name, it's not actually unrecoverable MAYDO: stop using that function

unsafeObjectCast
T unsafeObjectCast(Object obj)

A bit faster than a dynamic cast. This is to avoid TypeInfo look-up.

Structs

CStringImpl
struct CStringImpl(CharType)

Zero-terminated C string, to replace toStringz and toUTF16z

Meta