Skip to content

Commit

Permalink
Pre-allocate List<SafeMILHandle> from the retrieved Count
Browse files Browse the repository at this point in the history
  • Loading branch information
h3xds1nz committed Oct 1, 2024
1 parent 7d24ae2 commit 0c4aa52
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,24 +265,16 @@ public int InitializeFromBlockReader(
{
Invariant.Assert(pIBlockReader != IntPtr.Zero);

int hr = MS.Win32.NativeMethods.S_OK;

UInt32 count = 0;

Guid guidVendor = new Guid(MILGuidData.GUID_VendorMicrosoft);

List<SafeMILHandle> metadataBlocks = new();

hr = UnsafeNativeMethods.WICMetadataBlockReader.GetCount(
pIBlockReader,
out count
);

int hr = UnsafeNativeMethods.WICMetadataBlockReader.GetCount(pIBlockReader, out UInt32 count);
if (HRESULT.Succeeded(hr))
{
List<SafeMILHandle> metadataBlocks = new((int)count);

using (FactoryMaker factoryMaker = new FactoryMaker())
{
for (UInt32 i=0; i<count; i++)
for (UInt32 i = 0; i < count; i++)
{
SafeMILHandle pIMetadataReader = null;
IntPtr pIMetadataWriter = IntPtr.Zero;
Expand Down

0 comments on commit 0c4aa52

Please # to comment.