Use dispose from std.experimental

This commit is contained in:
2016-10-05 13:12:50 +02:00
parent 9241ec503c
commit 721bb110e5
11 changed files with 98 additions and 251 deletions

View File

@ -116,7 +116,7 @@ class ReadBuffer : Buffer
*/
~this()
{
finalize(allocator, _buffer);
dispose(allocator, _buffer);
}
///
@ -126,7 +126,7 @@ class ReadBuffer : Buffer
assert(b.capacity == 8192);
assert(b.length == 0);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
/**
@ -169,7 +169,7 @@ class ReadBuffer : Buffer
b[];
assert(b.free == b.blockSize);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
/**
@ -240,7 +240,7 @@ class ReadBuffer : Buffer
assert(result[10] == 20);
assert(result[14] == 24);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
/**
@ -275,7 +275,7 @@ class ReadBuffer : Buffer
assert(result[9] == 9);
assert(b.length == 0);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
}
@ -333,7 +333,7 @@ class WriteBuffer : Buffer
*/
~this()
{
finalize(allocator, _buffer);
dispose(allocator, _buffer);
}
/**
@ -385,7 +385,7 @@ class WriteBuffer : Buffer
b.written = b.length;
assert(b.length == 0);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
/**
@ -485,7 +485,7 @@ class WriteBuffer : Buffer
assert(b._buffer[0] == 23 && b._buffer[1] == 255
&& b._buffer[2] == 48 && b._buffer[3] == 23 && b._buffer[4] == 255);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
b = make!WriteBuffer(defaultAllocator, 2);
@ -495,7 +495,7 @@ class WriteBuffer : Buffer
assert(b.ring == 3);
assert(b.position == 3);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
/**
@ -578,7 +578,7 @@ class WriteBuffer : Buffer
b.written = 4;
assert(b.length == 0);
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
/**
@ -631,6 +631,6 @@ class WriteBuffer : Buffer
assert(returnedBuf[0..b.length] == buf[0..6]);
b.written = b.length;
finalize(defaultAllocator, b);
dispose(defaultAllocator, b);
}
}

View File

@ -42,7 +42,7 @@ class SList(T)
{
static if (isFinalizable!T)
{
finalize(allocator, front);
dispose(allocator, front);
}
popFront();
}
@ -87,7 +87,7 @@ class SList(T)
l.front = values[1];
assert(l.front == values[1]);
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/**
@ -118,7 +118,7 @@ class SList(T)
assert(l.front == value);
assert(!l.empty);
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/**
@ -144,7 +144,7 @@ class SList(T)
auto n = first.next.next;
auto content = first.next.content;
finalize(allocator, first.next);
dispose(allocator, first.next);
first.next = n;
return content;
@ -162,7 +162,7 @@ class SList(T)
l.popFront();
assert(l.front == values[0]);
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/**
@ -183,7 +183,7 @@ class SList(T)
auto temp = position.next.next;
auto content = position.next.content;
finalize(allocator, position.next);
dispose(allocator, position.next);
position.next = temp;
return content;
@ -203,7 +203,7 @@ class SList(T)
assert(l.remove() == 8);
assert(l.empty);
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/**
@ -231,7 +231,7 @@ class SList(T)
l.reset();
assert(l.current == 5);
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/**
@ -275,7 +275,7 @@ class SList(T)
assert(i != 2 || e == values[0]);
}
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/// Ditto.
@ -315,7 +315,7 @@ class SList(T)
++i;
}
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}
/**
@ -400,5 +400,5 @@ unittest
{
auto l = make!(SList!Stuff)(defaultAllocator);
finalize(defaultAllocator, l);
dispose(defaultAllocator, l);
}

View File

@ -41,7 +41,7 @@ class Queue(T)
{
static if (isFinalizable!T)
{
finalize(allocator, e);
dispose(allocator, e);
}
}
}
@ -99,7 +99,7 @@ class Queue(T)
q.insertBack(values[1]);
assert(q.front is values[0]);
finalize(defaultAllocator, q);
dispose(defaultAllocator, q);
}
/**
@ -129,7 +129,7 @@ class Queue(T)
assert(q.front == value);
assert(!q.empty);
finalize(defaultAllocator, q);
dispose(defaultAllocator, q);
}
/**
@ -150,7 +150,7 @@ class Queue(T)
q.insertBack(value);
assert(!q.empty);
finalize(defaultAllocator, q);
dispose(defaultAllocator, q);
}
/**
@ -167,7 +167,7 @@ class Queue(T)
{
auto n = first.next.next;
finalize(allocator, first.next);
dispose(allocator, first.next);
first.next = n;
return this;
@ -185,7 +185,7 @@ class Queue(T)
q.popFront();
assert(q.front is values[1]);
finalize(defaultAllocator, q);
dispose(defaultAllocator, q);
}
/**
@ -214,5 +214,5 @@ unittest
{
auto q = make!(Queue!int)(defaultAllocator);
finalize(defaultAllocator, q);
dispose(defaultAllocator, q);
}

View File

@ -22,7 +22,7 @@ import tanya.memory;
*
* v[1000] = value;
*
* finalize(defaultAllocator, v);
* dispose(defaultAllocator, v);
* ---
* it will allocate not only for one, but for 1000 elements. So this
* implementation is more suitable for sequential data with random access.
@ -57,7 +57,7 @@ class Vector(T)
*/
~this()
{
finalize(allocator, vector);
dispose(allocator, vector);
}
/**
@ -94,7 +94,7 @@ class Vector(T)
v.length = 0;
assert(v.length == 0);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -116,7 +116,7 @@ class Vector(T)
void remove(size_t pos)
{
auto el = vector[pos];
finalize(allocator, el);
dispose(allocator, el);
}
}
@ -151,7 +151,7 @@ class Vector(T)
v[4] = values[1];
assert(v.length == 5);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -182,7 +182,7 @@ class Vector(T)
v[0] = values[1];
assert(v[0] is values[1]);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -250,7 +250,7 @@ class Vector(T)
assert(j != 2 || e is values[2]);
}
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -289,7 +289,7 @@ class Vector(T)
v.front = values[1];
assert(v.front == 15);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -325,7 +325,7 @@ class Vector(T)
v.popFront();
assert(v.empty);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -364,7 +364,7 @@ class Vector(T)
v.back = values[1];
assert(v.back == 15);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/**
@ -399,7 +399,7 @@ class Vector(T)
v.popBack();
assert(v.empty);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}
/// Container.
@ -413,5 +413,5 @@ unittest
{
auto v = make!(Vector!int)(defaultAllocator);
finalize(defaultAllocator, v);
dispose(defaultAllocator, v);
}