Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a need to use Array.CreateInstance(typeof(byte)) to create b… #126

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sources/OpenMcdf/CompoundFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void Commit(bool releaseMemory)
CheckForLockSector();

sourceStream.Seek(0, SeekOrigin.Begin);
sourceStream.Write((byte[])Array.CreateInstance(typeof(byte), GetSectorSize()), 0, sSize);
sourceStream.Write(new byte[sSize], 0, sSize);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed the array size from GetSectorSize() to sSize (the sSize variable is initialized to GetSectorSize() above, but I didn't think it made sense for the call here to create the array with GetSectorSize size and then call Write with sSize as the size?


CommitDirectory();

Expand Down Expand Up @@ -2052,7 +2052,7 @@ public void Save(Stream stream)
}
}

stream.Write((byte[])Array.CreateInstance(typeof(byte), sSize), 0, sSize);
stream.Write(new byte[sSize], 0, sSize);

CommitDirectory();

Expand Down