Another workaround is to use GC.addRoot for dynamic allocated
data in Dynamic.proc
void proc () {
import core.memory: GC;
dash.length = 32;
GC.addRoot(cast(void*)dash.ptr);
dash[] = '-';
}
And another one is hold pointer to data:
class Dynamic {
static char[] space;
static char[] dash;
char* dash_ptr;
void rehash () {
static Hash hash ;
hash = new Hash;
hash.clear();
}
void proc () {
import core.memory: GC;
dash.length = 32;
dash_ptr = dash.ptr;
dash[] = '-';
}
}
Daniel, thanks for confirming the bug and for providing
workaround. The second workaround (saving the pointer) will not
work on my real project though. I have multiple threads and the
TLS variable will have a different pointer on each thread.
Also, can you please tell me how to addRoot an assoc array to GC.
It seems there is no ptr property available for assoc arrays.
Regards
- Puneet