1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

cpu[darwin]: fix Go arrays panic in cgo #279

This commit is contained in:
Shirou WAKAYAMA 2016-11-15 00:53:20 +09:00
parent a63900a44b
commit ae251eb6a2

View File

@ -57,7 +57,7 @@ func perCPUTimes() ([]TimesStat, error) {
// copy the cpuload array to a []byte buffer
// where we can binary.Read the data
size := int(ncpu) * binary.Size(cpu_ticks)
buf := C.GoBytes(unsafe.Pointer(cpuload), C.int(size))
buf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size]
bbuf := bytes.NewBuffer(buf)