On 31/12/2016 2:52 PM, David Zhang wrote:
Extracting everything into a main() also causes the application to hang.
ie:
struct S
{
S* next;
}
S* _foo;
foreach (e; 0 .. 10)
_foo = theAllocator.make!S(_foo);
S* next, current;
next = current = _foo;
while (next)
{
next = current.next;
theAllocator.dispose(current);
}
As it should, current is never reassigned.
You only need one var, next. Of course I didn't read the entire thread
chain so, I'm probably missing something.
import std.experimental.allocator;
void main() {
struct S { S* next; }
S* _foo;
foreach (e; 0 .. 10)
_foo = theAllocator.make!S(_foo);
S* next;
next = _foo;
while(next !is null) {
auto nextT = next.next;
theAllocator.dispose(next);
next = nextT;
}
}