scid.core.memory

Memory management. The code in this module is borrowed from David Simcha's dstats project, specifically the dstats.alloc module.

Members

Functions

appendDelOld
void appendDelOld(T[] to, U from)

Appends to an array, deleting the old array if it has to be realloced.

exit
void exit(int )
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
fprintf
int fprintf(shared(void*) , char* , ...)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lengthVoid
void lengthVoid(T[] input, int newLength)
Undocumented in source. Be warned that the author may not have intended to support it.
lengthVoid
void lengthVoid(T[] input, size_t newLength)

Lengthens an array w/o initializing new elements.

newStack
T[] newStack(size_t size, TempAlloc.State state)

Allocates an array of type T and size size using TempAlloc. * Note that appending to this array using the ~= operator, * or enlarging it using the .length property, will result in * undefined behavior. This is because, if the array is located * at the beginning of a TempAlloc block, the GC will think the * capacity is as large as a TempAlloc block, and will overwrite * adjacent TempAlloc-allocated data, instead of reallocating it. * * Bugs: Do not store the only reference to a GC-allocated reference object * in an array allocated by newStack because this memory is not * scanned by the GC.

newVoid
T[] newVoid(size_t length)

Returns a new array of type T w/o initializing elements.

rangeCopy
void rangeCopy(T to, U from)
Undocumented in source. Be warned that the author may not have intended to support it.
reserve
void reserve(T[] input, int newLength)
Undocumented in source. Be warned that the author may not have intended to support it.
reserve
void reserve(T[] input, size_t newLength)

Reserves more space for an array w/o changing its length or initializing * the space.

stackCat
T[0] stackCat(T data)

Concatenate any number of arrays of the same type, placing results on * the TempAlloc stack.

tempdup
Unqual!(ElementType!(T))[] tempdup(T data)

Creates a duplicate of a range for temporary use within a function in the best wsy that can be done safely. If ElementType!(T) is a value type or T is an array, the results can safely be placed in TempAlloc because either it doesn't need to be scanned by the GC or there's guaranteed to be another reference to the contents somewhere. Otherwise, the results are placed on the GC heap.

tempdup
Unqual!(ElementType!(T))[] tempdup(T data)
Undocumented in source. Be warned that the author may not have intended to support it.
toArray
Unqual!(IterType!(T))[] toArray(T range)

Converts any range to an array on the GC heap by the most efficient means * available. If it is already an array, duplicates the range.

Structs

TempAlloc
struct TempAlloc

A struct to allocate memory in a strictly first-in last-out order for things like scratch space. Technically, memory can safely escape the scope in which it was allocated. However, this is a very bad idea unless being done within the private API of a class, struct or nested function, where it can be guaranteed that LIFO will not be violated.

Templates

ArrayType1
template ArrayType1(T : T[])
Undocumented in source.
IsType
template IsType(T, Types...)
Undocumented in source.
blockAttribute
template blockAttribute(T)
Undocumented in source.
hasLength
template hasLength(R)
Undocumented in source.
isReferenceType
template isReferenceType(Types...)
Undocumented in source.

Variables

newFrame
char[] newFrame;

A string to mixin at the beginning of a scope, purely for * convenience. Initializes a TempAlloc frame using frameInit(), * and inserts a scope statement to delete this frame at the end * of the current scope. * * Slower than calling free() manually when only a few pieces * of memory will be allocated in the current scope, due to the * extra bookkeeping involved. Can be faster, however, when * large amounts of allocations, such as arrays of arrays, * are allocated, due to caching of data stored in thread-local * storage.

Meta

Authors

David Simcha

License

Boost License 1.0