Commit 03c40f51 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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
parent 6e4b9c69
......@@ -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);
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment