cmd/cgo: replace C.malloc with our own wrapper

This allows us to make two changes:

1. Force the argument type to be size_t, even on broken
   systems that declare malloc to take a ulong.

2. Call runtime.throw if malloc fails.
   (That is, the program crashes; it does not panic.)

Fixes #3403.
Fixes #5926.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13413047
This commit is contained in:
Russ Cox 2013-09-11 11:30:08 -04:00
parent 89b26760d7
commit 397ba2cb4a
4 changed files with 48 additions and 3 deletions

View file

@ -341,7 +341,7 @@ func (p *Package) Record(f *File) {
if p.Name[k] == nil {
p.Name[k] = v
} else if !reflect.DeepEqual(p.Name[k], v) {
error_(token.NoPos, "inconsistent definitions for C.%s", k)
error_(token.NoPos, "inconsistent definitions for C.%s", fixGo(k))
}
}
}