Skip to content

Commit

Permalink
Replace malloc call with stack alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettgu10 committed Feb 1, 2024
1 parent 2f37146 commit ed05ac1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/workerd/io/worker.c++
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,7 @@ static void stopProfiling(jsg::Lock& js,
}

auto hitLineCount = allNodes[i]->GetHitLineCount();
v8::CpuProfileNode::LineTick* lineBuffer =
(v8::CpuProfileNode::LineTick*)malloc(
hitLineCount * sizeof(v8::CpuProfileNode::LineTick));
KJ_DEFER(free(lineBuffer));
v8::CpuProfileNode::LineTick lineBuffer[hitLineCount];
allNodes[i]->GetLineTicks(lineBuffer, hitLineCount);

auto positionTicks = nodeBuilder.initPositionTicks(hitLineCount);
Expand Down

0 comments on commit ed05ac1

Please sign in to comment.