Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct AffixAllocator(Allocator, Prefix, Suffix = void)
}

static if (hasMember!(Allocator, "resolveInternalPointer"))
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
void[] p1;
Ternary r = parent.resolveInternalPointer(p, p1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ struct BitmappedBlockWithInternalPointers(
}

/// Ditto
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
if (p < _heap._payload.ptr
|| p >= _heap._payload.ptr + _heap._payload.length)
Expand Down
2 changes: 1 addition & 1 deletion std/experimental/allocator/building_blocks/bucketizer.d
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ struct Bucketizer(Allocator, size_t min, size_t max, size_t step)
resolveInternalPointer), and tries it for each bucket in turn.
*/
static if (hasMember!(Allocator, "resolveInternalPointer"))
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
foreach (ref a; buckets)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct FallbackAllocator(Primary, Fallback)
*/
static if (hasMember!(Primary, "resolveInternalPointer")
&& hasMember!(Fallback, "resolveInternalPointer"))
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
Ternary r = primary.resolveInternalPointer(p, result);
return r == Ternary.no ? fallback.resolveInternalPointer(p, result) : r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct NullAllocator
/**
Returns $(D Ternary.no).
*/
Ternary resolveInternalPointer(void*, ref void[]) shared const
Ternary resolveInternalPointer(const void*, ref void[]) shared const
{ return Ternary.no; }
/**
No-op.
Expand Down
2 changes: 1 addition & 1 deletion std/experimental/allocator/building_blocks/segregator.d
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct Segregator(size_t threshold, SmallAllocator, LargeAllocator)

static if (hasMember!(SmallAllocator, "resolveInternalPointer")
&& hasMember!(LargeAllocator, "resolveInternalPointer"))
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
Ternary r = _small.resolveInternalPointer(p, result);
return r == Ternary.no ? _large.resolveInternalPointer(p, result) : r;
Expand Down
5 changes: 3 additions & 2 deletions std/experimental/allocator/gc_allocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ struct GCAllocator
}

/// Ditto
pure nothrow Ternary resolveInternalPointer(void* p, ref void[] result) shared
pure nothrow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this entire function can be trusted, maybe in a later step

Ternary resolveInternalPointer(const void* p, ref void[] result) shared
{
auto r = GC.addrOf(p);
auto r = GC.addrOf(cast(void*)p);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style check failed:

Enforce space after cast(...)
grep -nrE '[^&quot;]cast\([^)]*?\)[[:alnum:]]' $(find . -name '*.d') ; test $? -eq 1
./std/experimental/allocator/gc_allocator.d:76:        auto r = GC.addrOf(cast(void*)p);

Please fix/revert :)

if (!r) return Ternary.no;
result = r[0 .. GC.sizeOf(r)];
return Ternary.yes;
Expand Down
6 changes: 3 additions & 3 deletions std/experimental/allocator/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ interface IAllocator
Resolves an internal pointer to the full block allocated. Implementations
that don't support this primitive should always return `Ternary.unknown`.
*/
Ternary resolveInternalPointer(void* p, ref void[] result);
Ternary resolveInternalPointer(const void* p, ref void[] result);

/**
Deallocates a memory block. Implementations that don't support this
Expand Down Expand Up @@ -1953,7 +1953,7 @@ class CAllocatorImpl(Allocator, Flag!"indirect" indirect = No.indirect)
}

// Undocumented for now
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
static if (hasMember!(Allocator, "resolveInternalPointer"))
{
Expand Down Expand Up @@ -2412,7 +2412,7 @@ private struct InternalPointersTree(Allocator)
/** Returns the block inside which $(D p) resides, or $(D null) if the
pointer does not belong.
*/
Ternary resolveInternalPointer(void* p, ref void[] result)
Ternary resolveInternalPointer(const void* p, ref void[] result)
{
// Must define a custom find
Tree.Node* find()
Expand Down