summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-09-30 08:15:02 +0200
committerEugen Wissner <belka@caraus.de>2017-09-30 08:15:02 +0200
commita576c36d021c866880ae6e3e64f055d3fc1dc7eb (patch)
tree2d598a48063078ddad3d2a1c23a2bfb33b5861e2
parent1056a2984e2d689c1f7a5c34008961f58343b04f (diff)
downloadtanya-a576c36d021c866880ae6e3e64f055d3fc1dc7eb.tar.gz
Replace memcpy/memmove with copy/copyBackwardv0.7.4
-rw-r--r--source/tanya/memory/mmappool.d26
1 files changed, 13 insertions, 13 deletions
diff --git a/source/tanya/memory/mmappool.d b/source/tanya/memory/mmappool.d
index feb25e4..6bfb1fe 100644
--- a/source/tanya/memory/mmappool.d
+++ b/source/tanya/memory/mmappool.d
@@ -14,9 +14,9 @@
*/
module tanya.memory.mmappool;
-import core.stdc.string;
import std.algorithm.comparison;
import tanya.memory.allocator;
+import tanya.memory.op;
version (Posix)
{
@@ -24,7 +24,7 @@ version (Posix)
MAP_ANON, MAP_FAILED;
import core.sys.posix.unistd;
- extern (C)
+ extern(C)
private void* mmap(void* addr,
size_t len,
int prot,
@@ -32,7 +32,7 @@ version (Posix)
int fd,
off_t offset) pure nothrow @system @nogc;
- extern (C)
+ extern(C)
private int munmap(void* addr, size_t len) pure nothrow @system @nogc;
private void* mapMemory(const size_t len) pure nothrow @system @nogc
@@ -56,11 +56,11 @@ else version (Windows)
{
import core.sys.windows.winbase : GetSystemInfo, SYSTEM_INFO;
- extern (Windows)
+ extern(Windows)
private void* VirtualAlloc(void*, size_t, uint, uint)
pure nothrow @system @nogc;
- extern (Windows)
+ extern(Windows)
private int VirtualFree(void* addr, size_t len, uint)
pure nothrow @system @nogc;
@@ -347,10 +347,10 @@ final class MmapPool : Allocator
|| dataSize < size
|| block1.next.size + BlockEntry.sizeof < delta)
{
- /* * It is the last block in the region
- * * The next block is too small
- * * The next block isn't free
- * * Requested size is too large
+ /* - It is the last block in the region
+ * - The next block isn't free
+ * - The next block is too small
+ * - Requested size is too large
*/
return false;
}
@@ -365,8 +365,8 @@ final class MmapPool : Allocator
{
block1.next.next.prev = block2;
}
- // block1.next and block2 can overlap.
- memmove(cast(void*) block2, cast(void*) block1.next, BlockEntry.sizeof);
+ copyBackward((cast(void*) block1.next)[0 .. BlockEntry.sizeof],
+ (cast(void*) block2)[0 .. BlockEntry.sizeof]);
block1.next = block2;
}
else
@@ -438,7 +438,7 @@ final class MmapPool : Allocator
}
if (p !is null)
{
- memcpy(reallocP.ptr, p.ptr, min(p.length, size));
+ copy(p[0 .. min(p.length, size)], reallocP);
deallocate(p);
}
p = reallocP;
@@ -502,7 +502,7 @@ final class MmapPool : Allocator
void* data = initializeRegion(instanceSize, head, pageSize);
if (data !is null)
{
- memcpy(data, typeid(MmapPool).initializer.ptr, instanceSize);
+ copy(typeid(MmapPool).initializer, data[0 .. instanceSize]);
instance_ = cast(shared MmapPool) data;
instance_.head = head;
instance_.pageSize = pageSize;