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:
parent
a63900a44b
commit
ae251eb6a2
@ -57,7 +57,7 @@ func perCPUTimes() ([]TimesStat, error) {
|
|||||||
// copy the cpuload array to a []byte buffer
|
// copy the cpuload array to a []byte buffer
|
||||||
// where we can binary.Read the data
|
// where we can binary.Read the data
|
||||||
size := int(ncpu) * binary.Size(cpu_ticks)
|
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)
|
bbuf := bytes.NewBuffer(buf)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user