Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Initialize stack allocated data structures. (dotnet/coreclr#16259)
Browse files Browse the repository at this point in the history
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
brianrob authored and dotnet-bot committed Feb 11, 2018
1 parent c73a631 commit 266b019
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ private unsafe void WriteMultiMergeInner(
var pinCount = eventTypes.pinCount;
var scratch = stackalloc byte[eventTypes.scratchSize];
var descriptors = stackalloc EventData[eventTypes.dataCount + 3];
for(int i = 0; i < eventTypes.dataCount + 3; i++)
descriptors[i] = default(EventData);

var pins = stackalloc GCHandle[pinCount];
for (int i = 0; i < pinCount; i++)
Expand Down Expand Up @@ -538,7 +540,10 @@ internal unsafe void WriteMultiMerge(

// We make a descriptor for each EventData, and because we morph strings to counted strings
// we may have 2 for each arg, so we allocate enough for this.
var descriptors = stackalloc EventData[eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3];
var descriptorsLength = eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3;
var descriptors = stackalloc EventData[descriptorsLength];
for(int i = 0; i < descriptorsLength; i++)
descriptors[i] = default(EventData);

fixed (byte*
pMetadata0 = this.providerMetadata,
Expand Down Expand Up @@ -614,6 +619,8 @@ private unsafe void WriteImpl(
var pinCount = eventTypes.pinCount;
var scratch = stackalloc byte[eventTypes.scratchSize];
var descriptors = stackalloc EventData[eventTypes.dataCount + 3];
for(int i=0; i<eventTypes.dataCount + 3; i++)
descriptors[i] = default(EventData);

var pins = stackalloc GCHandle[pinCount];
for (int i = 0; i < pinCount; i++)
Expand Down

0 comments on commit 266b019

Please sign in to comment.