Skip to content

Commit

Permalink
make @safe
Browse files Browse the repository at this point in the history
Signed-off-by: denisa.ciobanu1208 <[email protected]>
  • Loading branch information
denisa.ciobanu1208 committed Dec 12, 2024
1 parent b925c16 commit b9bbe95
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions std/experimental/allocator/building_blocks/kernighan_ritchie.d
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@ struct KRRegion(ParentAllocator = NullAllocator)

this(this) @disable;

pure nothrow @trusted @nogc
pure nothrow @safe @nogc
void[] payload() inout
{
return (cast(ubyte*) &this)[0 .. size];
}

pure nothrow @trusted @nogc
pure nothrow @safe @nogc
bool adjacent(in Node* right) const
{
assert(right);
auto p = payload;
return p.ptr < right && right < p.ptr + p.length + Node.sizeof;
}

pure nothrow @trusted @nogc
pure nothrow @safe @nogc
bool coalesce(void* memoryEnd = null)
{
// Coalesce the last node before the memory end with any possible gap
Expand Down Expand Up @@ -156,7 +156,7 @@ struct KRRegion(ParentAllocator = NullAllocator)
if (leftover >= Node.sizeof)
{
// There's room for another node
auto newNode = (() @trusted => cast(Node*) ((cast(ubyte*) &this) + bytes))();
auto newNode = (() @safe => cast(Node*) ((cast(ubyte*) &this) + bytes))();
newNode.size = leftover;
newNode.next = next == &this ? newNode : next;
assert(next);
Expand Down Expand Up @@ -418,7 +418,7 @@ struct KRRegion(ParentAllocator = NullAllocator)
immutable balance = root.size - actualBytes;
if (balance >= Node.sizeof)
{
auto newRoot = (() @trusted => cast(Node*) (result + actualBytes))();
auto newRoot = (() @safe => cast(Node*) (result + actualBytes))();
newRoot.next = root.next;
newRoot.size = balance;
root = newRoot;
Expand All @@ -428,7 +428,7 @@ struct KRRegion(ParentAllocator = NullAllocator)
root = null;
switchToFreeList;
}
return (() @trusted => result[0 .. n])();
return (() @safe => result[0 .. n])();
}

// Not enough memory, switch to freelist mode and fall through
Expand Down Expand Up @@ -604,7 +604,7 @@ struct KRRegion(ParentAllocator = NullAllocator)
It does a simple $(BIGOH 1) range check. `b` should be a buffer either
allocated with `this` or obtained through other means.
*/
pure nothrow @trusted @nogc
pure nothrow @safe @nogc
Ternary owns(void[] b)
{
debug(KRRegion) assertValid("owns");
Expand Down Expand Up @@ -942,3 +942,4 @@ version (StdUnittest)
assert(alloc.deallocate(k));
assert(alloc.empty == Ternary.yes);
}

0 comments on commit b9bbe95

Please sign in to comment.