From b9bbe9583ea97a81e9f58833618292c67221d4da Mon Sep 17 00:00:00 2001 From: "denisa.ciobanu1208" Date: Thu, 12 Dec 2024 15:08:18 +0200 Subject: [PATCH] make @safe Signed-off-by: denisa.ciobanu1208 --- .../allocator/building_blocks/kernighan_ritchie.d | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/std/experimental/allocator/building_blocks/kernighan_ritchie.d b/std/experimental/allocator/building_blocks/kernighan_ritchie.d index 328497f44d3..d7b363c348f 100644 --- a/std/experimental/allocator/building_blocks/kernighan_ritchie.d +++ b/std/experimental/allocator/building_blocks/kernighan_ritchie.d @@ -111,13 +111,13 @@ 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); @@ -125,7 +125,7 @@ struct KRRegion(ParentAllocator = NullAllocator) 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 @@ -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); @@ -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; @@ -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 @@ -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"); @@ -942,3 +942,4 @@ version (StdUnittest) assert(alloc.deallocate(k)); assert(alloc.empty == Ternary.yes); } +