]> Cypherpunks repositories - gostls13.git/commitdiff
Change malloc.Lookup to return the size as uintptr rather than
authorIan Lance Taylor <iant@golang.org>
Fri, 16 Jan 2009 23:03:22 +0000 (15:03 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 16 Jan 2009 23:03:22 +0000 (15:03 -0800)
uint64.  This changes the Go code to be consistent with the C
code.

R=rsc
DELTA=6  (0 added, 0 deleted, 6 changed)
OCL=22983
CL=22987

src/lib/malloc.go
test/mallocrep1.go

index f10720b4cff4e0a7813b2a0885766b701d770249..3b81b4ed02898a5d858e688dde65dc5a898d05d4 100644 (file)
@@ -16,4 +16,4 @@ export type Stats struct {
 export func Alloc(uint64) *byte;
 export func Free(*byte);
 export func GetStats() *Stats;
-export func Lookup(*byte) (*byte, uint64);
+export func Lookup(*byte) (*byte, uintptr);
index 5ae742b4c77fc6ad3da72456f055faf29fd01af9..7ae6b36829821d5b3cab4e11078b3ae6e57e711a 100644 (file)
@@ -22,7 +22,7 @@ var longtest = flag.Bool("l", false, "long test");
 var b []*byte;
 var stats = malloc.GetStats();
 
-func OkAmount(size, n uint64) bool {
+func OkAmount(size, n uintptr) bool {
        if n < size {
                return false
        }
@@ -46,7 +46,7 @@ func AllocAndFree(size, count int) {
        for i := 0; i < count; i++ {
                b[i] = malloc.Alloc(uint64(size));
                base, n := malloc.Lookup(b[i]);
-               if base != b[i] || !OkAmount(uint64(size), n) {
+               if base != b[i] || !OkAmount(uintptr(size), n) {
                        panicln("lookup failed: got", base, n, "for", b[i]);
                }
                if malloc.GetStats().sys > 1e9 {
@@ -65,12 +65,12 @@ func AllocAndFree(size, count int) {
                }
                alloc := stats.alloc;
                base, n := malloc.Lookup(b[i]);
-               if base != b[i] || !OkAmount(uint64(size), n) {
+               if base != b[i] || !OkAmount(uintptr(size), n) {
                        panicln("lookup failed: got", base, n, "for", b[i]);
                }
                malloc.Free(b[i]);
-               if stats.alloc != alloc - n {
-                       panicln("free alloc got", stats.alloc, "expected", alloc - n, "after free of", n);
+               if stats.alloc != alloc - uint64(n) {
+                       panicln("free alloc got", stats.alloc, "expected", alloc - uint64(n), "after free of", n);
                }
                if malloc.GetStats().sys > 1e9 {
                        panicln("too much memory allocated");