Module scid.core.memory

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

Functions

Name Description
appendDelOld Appends to an array, deleting the old array if it has to be realloced.
exit
fprintf
lengthVoid
lengthVoid Lengthens an array w/o initializing new elements.
newStack 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.
newVoid Returns a new array of type T w/o initializing elements.
rangeCopy
reserve
reserve Reserves more space for an array w/o changing its length or initializing the space.
stackCat **Same as newStack(size_t) but uses stateCopy cached on stack by caller
tempdup 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
toArray 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

Name Description
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

Name Description
blockAttribute
isReferenceType
IsType

Enum values

Name Type Description
hasLength

Global variables

Name Type Description
newFrame immutable(char[]) 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.

Aliases

Name Type Description
ArrayType1 T

Authors

David Simcha

Copyright

License

Boost License 1.0