DMD 1.001 release
Walter Bright
newshound at digitalmars.com
Wed Jan 24 02:04:23 PST 2007
Tomas Lindquist Olsen wrote:
> Let me clarify what I mean. Consider this code:
>
> import std.gc;
>
> void test()
> {
> void[] buf = new void[1024];
> std.gc.hasNoPointers(ret.ptr);
> // invoking gc will not scan buf. ok
> buf.length = buf.length*2;
> // could invoking gc now potentially scan buf?
> }
>
> I'm thinking how to make sure a void[] is _never_ scanned.
> A somewhat realistic case for this would be (again) the std.file.read
> function.
> If we append some data to this buffer will the GC be smart enough to
> know it still holds no pointers? That is even with the reallocation and
> potential relocation.
It'll reallocate based on the type of buf, which is void[], so you'll
need to invoke gc.hasNoPointers again.
> Is a ubyte[] safe from this problem? (if it even exists)
ubyte[]s won't get scanned for pointers.
More information about the Digitalmars-d-announce
mailing list