From: Russ Cox Date: Wed, 27 May 2009 00:39:25 +0000 (-0700) Subject: add NUL when allocating strings, to make use X-Git-Tag: weekly.2009-11-06~1537 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1a0a6f9d5004d0ae078d7772e9623f9f6117f9be;p=gostls13.git add NUL when allocating strings, to make use of getenv by low-level runtime easier. fix 32-bit bug in gc (there are still more). R=ken OCL=29415 CL=29415 --- diff --git a/src/runtime/mgc0.c b/src/runtime/mgc0.c index 9c4061f6ec..d58d6ce44d 100644 --- a/src/runtime/mgc0.c +++ b/src/runtime/mgc0.c @@ -22,6 +22,10 @@ enum { extern byte etext[]; extern byte end[]; +enum { + PtrSize = sizeof(void*) +}; + static void scanblock(int32 depth, byte *b, int64 n) { @@ -34,14 +38,14 @@ scanblock(int32 depth, byte *b, int64 n) if(Debug) printf("%d scanblock %p %D\n", depth, b, n); - off = (uint32)(uintptr)b & 7; + off = (uint32)(uintptr)b & (PtrSize-1); if(off) { - b += 8 - off; - n -= 8 - off; + b += PtrSize - off; + n -= PtrSize - off; } vp = (void**)b; - n /= 8; + n /= PtrSize; for(i=0; i maxstring) maxstring = l;