Skip to content

Commit

Permalink
Correctly allocate slices when converting profile structs (grafana/ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena authored Mar 8, 2023
1 parent 687cd40 commit 7f6644f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/pprof/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func FromBytes(input []byte) (*profilev1.Profile, int, error) {
func FromProfile(p *profile.Profile) (*profilev1.Profile, error) {
r := profilev1.ProfileFromVTPool()
strings := make(map[string]int)

r.Sample = make([]*profilev1.Sample, 0, len(p.Sample))
r.SampleType = make([]*profilev1.ValueType, 0, len(p.SampleType))
r.Location = make([]*profilev1.Location, 0, len(p.Location))
r.Mapping = make([]*profilev1.Mapping, 0, len(p.Mapping))
r.Function = make([]*profilev1.Function, 0, len(p.Function))

addString(strings, "")
for _, st := range p.SampleType {
r.SampleType = append(r.SampleType, &profilev1.ValueType{
Expand Down

0 comments on commit 7f6644f

Please sign in to comment.