Skip to content

Commit

Permalink
Use Unsafe.InitBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
xtqqczze committed May 9, 2023
1 parent 68c1005 commit b593c9b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ internal abstract class DbBuffer : SafeHandle

protected unsafe DbBuffer(int initialSize) : base(IntPtr.Zero, true)
{
Debug.Assert(initialSize % IntPtr.Size == 0, $"Expected aligned {nameof(initialSize)}.");

if (0 < initialSize)
{
_bufferLength = initialSize;
Expand Down Expand Up @@ -627,7 +629,7 @@ internal unsafe void WriteSingle(int offset, float value)
WriteInt32(offset, BitConverter.SingleToInt32Bits(value));
}

internal void ZeroMemory()
internal unsafe void ZeroMemory()
{
bool mustRelease = false;

Expand All @@ -636,7 +638,7 @@ internal void ZeroMemory()
DangerousAddRef(ref mustRelease);

IntPtr ptr = DangerousGetHandle();
SafeNativeMethods.ZeroMemory(ptr, Length);
Unsafe.InitBlock((void*)ptr, 0, (uint)Length);
}
finally
{
Expand Down
1 change: 0 additions & 1 deletion src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ System.Data.Odbc.OdbcTransaction</PackageDescription>
<Compile Include="$(CommonPath)System\Data\Common\NameValuePair.cs"
Link="Common\System\Data\Common\NameValuePair.cs" />
<Compile Include="Common\System\Data\Common\NameValuePermission.cs" />
<Compile Include="Common\System\Data\Common\SafeNativeMethods.cs" />
<Compile Include="Common\System\Data\DataStorage.cs" />
<Compile Include="Common\System\Data\ProviderBase\DbBuffer.cs" />
<Compile Include="$(CommonPath)System\Data\Common\FieldNameLookup.cs"
Expand Down

0 comments on commit b593c9b

Please sign in to comment.