Replace memcpy/memmove with copy/copyBackward
This commit is contained in:
parent
1056a2984e
commit
a576c36d02
@ -14,9 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
module tanya.memory.mmappool;
|
module tanya.memory.mmappool;
|
||||||
|
|
||||||
import core.stdc.string;
|
|
||||||
import std.algorithm.comparison;
|
import std.algorithm.comparison;
|
||||||
import tanya.memory.allocator;
|
import tanya.memory.allocator;
|
||||||
|
import tanya.memory.op;
|
||||||
|
|
||||||
version (Posix)
|
version (Posix)
|
||||||
{
|
{
|
||||||
@ -347,10 +347,10 @@ final class MmapPool : Allocator
|
|||||||
|| dataSize < size
|
|| dataSize < size
|
||||||
|| block1.next.size + BlockEntry.sizeof < delta)
|
|| block1.next.size + BlockEntry.sizeof < delta)
|
||||||
{
|
{
|
||||||
/* * It is the last block in the region
|
/* - It is the last block in the region
|
||||||
* * The next block is too small
|
* - The next block isn't free
|
||||||
* * The next block isn't free
|
* - The next block is too small
|
||||||
* * Requested size is too large
|
* - Requested size is too large
|
||||||
*/
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -365,8 +365,8 @@ final class MmapPool : Allocator
|
|||||||
{
|
{
|
||||||
block1.next.next.prev = block2;
|
block1.next.next.prev = block2;
|
||||||
}
|
}
|
||||||
// block1.next and block2 can overlap.
|
copyBackward((cast(void*) block1.next)[0 .. BlockEntry.sizeof],
|
||||||
memmove(cast(void*) block2, cast(void*) block1.next, BlockEntry.sizeof);
|
(cast(void*) block2)[0 .. BlockEntry.sizeof]);
|
||||||
block1.next = block2;
|
block1.next = block2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -438,7 +438,7 @@ final class MmapPool : Allocator
|
|||||||
}
|
}
|
||||||
if (p !is null)
|
if (p !is null)
|
||||||
{
|
{
|
||||||
memcpy(reallocP.ptr, p.ptr, min(p.length, size));
|
copy(p[0 .. min(p.length, size)], reallocP);
|
||||||
deallocate(p);
|
deallocate(p);
|
||||||
}
|
}
|
||||||
p = reallocP;
|
p = reallocP;
|
||||||
@ -502,7 +502,7 @@ final class MmapPool : Allocator
|
|||||||
void* data = initializeRegion(instanceSize, head, pageSize);
|
void* data = initializeRegion(instanceSize, head, pageSize);
|
||||||
if (data !is null)
|
if (data !is null)
|
||||||
{
|
{
|
||||||
memcpy(data, typeid(MmapPool).initializer.ptr, instanceSize);
|
copy(typeid(MmapPool).initializer, data[0 .. instanceSize]);
|
||||||
instance_ = cast(shared MmapPool) data;
|
instance_ = cast(shared MmapPool) data;
|
||||||
instance_.head = head;
|
instance_.head = head;
|
||||||
instance_.pageSize = pageSize;
|
instance_.pageSize = pageSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user