Merge pull request #280 from shirou/darwin-goslices

cpu[darwin]: fix Go arrays panic in cgo #279
pull/283/head
shirou 8 years ago committed by GitHub
commit 110eb1f082

@ -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…
Cancel
Save