The OpenD Programming Language

GC.BlkAttr

Elements for a bit field representing memory block attributes. These are manipulated via the getAttr, setAttr, clrAttr functions.

Values

ValueMeaning
NONE0b0000_0000

No attributes set.

FINALIZE0b0000_0001

Finalize the data in this block on collect.

NO_SCAN0b0000_0010

Do not scan through this block on collect.

NO_MOVE0b0000_0100

Do not move this memory block on collect.

APPENDABLE0b0000_1000

This block contains the info to allow appending.

This can be used to manually allocate arrays. Initial slice size is 0.

Note: The slice's usable size will not match the block size. Use capacity to retrieve actual usable capacity.

Example:

// Allocate the underlying array.
int*  pToArray = cast(int*)GC.malloc(10 * int.sizeof, GC.BlkAttr.NO_SCAN | GC.BlkAttr.APPENDABLE);
// Bind a slice. Check the slice has capacity information.
int[] slice = pToArray[0 .. 0];
assert(capacity(slice) > 0);
// Appending to the slice will not relocate it.
slice.length = 5;
slice ~= 1;
assert(slice.ptr == p);
NO_INTERIOR0b0001_0000

This block is guaranteed to have a pointer to its base while it is alive. Interior pointers can be safely ignored. This attribute is useful for eliminating false pointers in very large data structures and is only implemented for data structures at least a page in size.

STRUCTFINAL0b0010_0000

Meta