Skip to content

Commit

Permalink
Allocate children array with count (rogchap#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
Genevieve authored Dec 13, 2021
1 parent 6e4af34 commit e635d48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cpuprofiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ func newCPUProfileNode(node *C.CPUProfileNode, parent *CPUProfileNode) *CPUProfi
}

if node.childrenCount > 0 {
for _, child := range (*[1 << 28]*C.CPUProfileNode)(unsafe.Pointer(node.children))[:node.childrenCount:node.childrenCount] {
n.children = append(n.children, newCPUProfileNode(child, n))
n.children = make([]*CPUProfileNode, node.childrenCount)
for i, child := range (*[1 << 28]*C.CPUProfileNode)(unsafe.Pointer(node.children))[:node.childrenCount:node.childrenCount] {
n.children[i] = newCPUProfileNode(child, n)
}
}

Expand Down

0 comments on commit e635d48

Please sign in to comment.