Skip to content

Commit

Permalink
Merge pull request #4679 from wilzbach/allocator_safe_1
Browse files Browse the repository at this point in the history
Add attributes to GCAllocator and theAllocator
  • Loading branch information
andralex authored Aug 15, 2016
2 parents c38d0d1 + a5b0016 commit c8e0c6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions std/experimental/allocator/gc_allocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct GCAllocator
deallocate) and $(D reallocate) methods are $(D @system) because they may
move memory around, leaving dangling pointers in user code.
*/
@trusted void[] allocate(size_t bytes) shared
pure nothrow @trusted void[] allocate(size_t bytes) shared
{
if (!bytes) return null;
auto p = GC.malloc(bytes);
Expand Down Expand Up @@ -52,7 +52,7 @@ struct GCAllocator
}

/// Ditto
@system bool reallocate(ref void[] b, size_t newSize) shared
pure nothrow @system bool reallocate(ref void[] b, size_t newSize) shared
{
import core.exception : OutOfMemoryError;
try
Expand All @@ -69,15 +69,15 @@ struct GCAllocator
}

/// Ditto
void[] resolveInternalPointer(void* p) shared
pure nothrow void[] resolveInternalPointer(void* p) shared
{
auto r = GC.addrOf(p);
if (!r) return null;
return r[0 .. GC.sizeOf(r)];
}

/// Ditto
@system bool deallocate(void[] b) shared
pure nothrow @system bool deallocate(void[] b) shared
{
GC.free(b.ptr);
return true;
Expand Down Expand Up @@ -110,7 +110,7 @@ struct GCAllocator
static shared GCAllocator instance;

// Leave it undocummented for now.
@trusted void collect() shared
nothrow @trusted void collect() shared
{
GC.collect();
}
Expand Down
4 changes: 2 additions & 2 deletions std/experimental/allocator/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ to be shared across threads, use $(D processAllocator) (below). By default,
$(D theAllocator) ultimately fetches memory from $(D processAllocator), which
in turn uses the garbage collected heap.
*/
@property IAllocator theAllocator()
nothrow @safe @nogc @property IAllocator theAllocator()
{
return _threadAllocator;
}

/// Ditto
@property void theAllocator(IAllocator a)
nothrow @safe @nogc @property void theAllocator(IAllocator a)
{
assert(a);
_threadAllocator = a;
Expand Down

0 comments on commit c8e0c6e

Please sign in to comment.