Skip to content

Commit

Permalink
Allocate children array with count (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
Genevieve committed 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
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.