View source code
Display the source code in core/memory.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Enum core.memory.member GC.BlkAttr.APPENDABLE
This block contains the info to allow appending.
This can be used to manually allocate arrays. Initial slice size is 0.
Declaration
enum GC.BlkAttr { // ... APPENDABLE = 8u, // ... }
Note
The slice's useable size will not match the block size. Use capacity to retrieve actual useable 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);
Authors
Sean Kelly, Alex Rønne Petersen