From: Ian Lance Taylor Date: Fri, 16 Jan 2009 23:03:22 +0000 (-0800) Subject: Change malloc.Lookup to return the size as uintptr rather than X-Git-Tag: weekly.2009-11-06~2337 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=03c40f5122eeb9b9abc4492c043af9e033c1503a;p=gostls13.git Change malloc.Lookup to return the size as uintptr rather than 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 --- diff --git a/src/lib/malloc.go b/src/lib/malloc.go index f10720b4cf..3b81b4ed02 100644 --- a/src/lib/malloc.go +++ b/src/lib/malloc.go @@ -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); diff --git a/test/mallocrep1.go b/test/mallocrep1.go index 5ae742b4c7..7ae6b36829 100644 --- a/test/mallocrep1.go +++ b/test/mallocrep1.go @@ -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");