# dmd.root.region

Region storage allocator implementation.

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: root/region.d

Documentation: https://dlang.org/phobos/dmd_root_region.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/region.d

- `Region`

  #### Declaration

  `struct `Region`;`

  Simple region storage allocator.

  - `malloc`

    #### Declaration

    `nothrow void* `malloc`(size_t `nbytes`);`

    Allocate `nbytes`. Aborts on failure.

    #### Parameters

    `size_t `nbytes`` | number of bytes to allocate, can be 0, must be <= than MaxAllocSize

    #### Return Value

    allocated data, `null` for `nbytes`==0

  - `savePos`

    #### Declaration

    `pure nothrow @nogc @safe RegionPos `savePos`();`

    Return stack position for allocations in this region.

    #### Return Value

    an opaque struct to be passed to `release()`

  - `release`

    #### Declaration

    `pure nothrow @nogc @safe void `release`(RegionPos `pos`);`

    Release the memory that was allocated after the respective call to `savePos()`.

    #### Parameters

    `RegionPos `pos`` | position returned by `savePos()`

  - `contains`

    #### Declaration

    `pure nothrow @nogc bool `contains`(void* `p`);`

    If pointer points into Region.

    #### Parameters

    `void* `p`` | pointer to check

    #### Return Value

    `true` if it points into the region

  - `size`

    #### Declaration

    `pure nothrow @nogc @safe size_t `size`();`

    #### Return Value

    `size` of Region