Skip to content

Commit c8e0c6e

Browse files
authored
Merge pull request #4679 from wilzbach/allocator_safe_1
Add attributes to GCAllocator and theAllocator
2 parents c38d0d1 + a5b0016 commit c8e0c6e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

std/experimental/allocator/gc_allocator.d

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct GCAllocator
2121
deallocate) and $(D reallocate) methods are $(D @system) because they may
2222
move memory around, leaving dangling pointers in user code.
2323
*/
24-
@trusted void[] allocate(size_t bytes) shared
24+
pure nothrow @trusted void[] allocate(size_t bytes) shared
2525
{
2626
if (!bytes) return null;
2727
auto p = GC.malloc(bytes);
@@ -52,7 +52,7 @@ struct GCAllocator
5252
}
5353

5454
/// Ditto
55-
@system bool reallocate(ref void[] b, size_t newSize) shared
55+
pure nothrow @system bool reallocate(ref void[] b, size_t newSize) shared
5656
{
5757
import core.exception : OutOfMemoryError;
5858
try
@@ -69,15 +69,15 @@ struct GCAllocator
6969
}
7070

7171
/// Ditto
72-
void[] resolveInternalPointer(void* p) shared
72+
pure nothrow void[] resolveInternalPointer(void* p) shared
7373
{
7474
auto r = GC.addrOf(p);
7575
if (!r) return null;
7676
return r[0 .. GC.sizeOf(r)];
7777
}
7878

7979
/// Ditto
80-
@system bool deallocate(void[] b) shared
80+
pure nothrow @system bool deallocate(void[] b) shared
8181
{
8282
GC.free(b.ptr);
8383
return true;
@@ -110,7 +110,7 @@ struct GCAllocator
110110
static shared GCAllocator instance;
111111

112112
// Leave it undocummented for now.
113-
@trusted void collect() shared
113+
nothrow @trusted void collect() shared
114114
{
115115
GC.collect();
116116
}

std/experimental/allocator/package.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,13 @@ to be shared across threads, use $(D processAllocator) (below). By default,
358358
$(D theAllocator) ultimately fetches memory from $(D processAllocator), which
359359
in turn uses the garbage collected heap.
360360
*/
361-
@property IAllocator theAllocator()
361+
nothrow @safe @nogc @property IAllocator theAllocator()
362362
{
363363
return _threadAllocator;
364364
}
365365

366366
/// Ditto
367-
@property void theAllocator(IAllocator a)
367+
nothrow @safe @nogc @property void theAllocator(IAllocator a)
368368
{
369369
assert(a);
370370
_threadAllocator = a;

0 commit comments

Comments
 (0)