# 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

    `nothrow RegionPos `savePos`();`

    Return stack position for allocations in this region.

    #### Return Value

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

  - `release`

    #### Declaration

    `nothrow 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

    `nothrow 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

    `nothrow size_t `size`();`

    #### Return Value

    `size` of Region