1
0
mirror of https://github.com/golang/go synced 2024-11-25 03:07:56 -07:00

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
This commit is contained in:
Ian Lance Taylor 2009-01-16 15:03:22 -08:00
parent 6e4b9c696f
commit 03c40f5122
2 changed files with 6 additions and 6 deletions

View 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);

View 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");