mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: merge mallocgc, gomallocgc
I assumed they were the same when I wrote cgocallback.go earlier today. Merge them to eliminate confusion. I can't tell what gomallocgc did before with a nil type but without FlagNoScan. I created a call like that in cgocallback.go this morning, translating from a C file. It was supposed to do what the C version did, namely treat the block conservatively. Now it will. LGTM=khr R=khr CC=golang-codereviews https://golang.org/cl/141810043
This commit is contained in:
parent
0f99a91bb5
commit
bffb0590c1
13 changed files with 33 additions and 44 deletions
|
|
@ -192,7 +192,7 @@ func stringiter2(s string, k int) (int, rune) {
|
|||
// The storage is not zeroed. Callers should use
|
||||
// b to set the string contents and then drop b.
|
||||
func rawstring(size int) (s string, b []byte) {
|
||||
p := gomallocgc(uintptr(size), nil, flagNoScan|flagNoZero)
|
||||
p := mallocgc(uintptr(size), nil, flagNoScan|flagNoZero)
|
||||
|
||||
(*stringStruct)(unsafe.Pointer(&s)).str = p
|
||||
(*stringStruct)(unsafe.Pointer(&s)).len = size
|
||||
|
|
@ -212,7 +212,7 @@ func rawstring(size int) (s string, b []byte) {
|
|||
// rawbyteslice allocates a new byte slice. The byte slice is not zeroed.
|
||||
func rawbyteslice(size int) (b []byte) {
|
||||
cap := goroundupsize(uintptr(size))
|
||||
p := gomallocgc(cap, nil, flagNoScan|flagNoZero)
|
||||
p := mallocgc(cap, nil, flagNoScan|flagNoZero)
|
||||
if cap != uintptr(size) {
|
||||
memclr(add(p, uintptr(size)), cap-uintptr(size))
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ func rawruneslice(size int) (b []rune) {
|
|||
gothrow("out of memory")
|
||||
}
|
||||
mem := goroundupsize(uintptr(size) * 4)
|
||||
p := gomallocgc(mem, nil, flagNoScan|flagNoZero)
|
||||
p := mallocgc(mem, nil, flagNoScan|flagNoZero)
|
||||
if mem != uintptr(size)*4 {
|
||||
memclr(add(p, uintptr(size)*4), mem-uintptr(size)*4)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue