Skip to content

Commit ceed6d6

Browse files
authored
Remove unnecessary memsets from code base (#3079)
***NO_CI***
1 parent b376aa8 commit ceed6d6

29 files changed

+24
-142
lines changed

src/CLR/CorLib/corlib_native_System_Array.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -15,8 +15,6 @@ HRESULT Library_corlib_native_System_Array::System_Collections_IList_get_Item___
1515

1616
CLR_RT_HeapBlock ref;
1717

18-
memset(&ref, 0, sizeof(struct CLR_RT_HeapBlock));
19-
2018
NANOCLR_CHECK_HRESULT(ref.InitializeArrayReference(thisRef, index));
2119

2220
{
@@ -40,8 +38,6 @@ HRESULT Library_corlib_native_System_Array::System_Collections_IList_set_Item___
4038

4139
CLR_RT_HeapBlock ref;
4240

43-
memset(&ref, 0, sizeof(struct CLR_RT_HeapBlock));
44-
4541
NANOCLR_CHECK_HRESULT(ref.InitializeArrayReference(thisRef, index));
4642

4743
NANOCLR_SET_AND_LEAVE(stack.Arg2().StoreToReference(ref, 0));

src/CLR/CorLib/corlib_native_System_Exception.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ HRESULT Library_corlib_native_System_Exception::get_StackTrace___STRING(CLR_RT_S
5050
CLR_RT_HeapBlock tmpArray;
5151
CLR_RT_HeapBlock *pThis;
5252

53-
memset(&tmpArray, 0, sizeof(struct CLR_RT_HeapBlock));
5453
tmpArray.SetObjectReference(NULL);
5554
CLR_RT_ProtectFromGC gc(tmpArray);
5655

src/CLR/CorLib/corlib_native_System_Reflection_Assembly.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,6 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR
295295

296296
header = (CLR_RECORD_ASSEMBLY *)array->GetFirstElement();
297297

298-
memset(&hbTimeout, 0, sizeof(struct CLR_RT_HeapBlock));
299-
300298
// !! need to cast to CLR_INT64 otherwise it wont setup a proper timeout
301299
hbTimeout.SetInteger((CLR_INT64)2 * CLR_RT_Thread::c_TimeQuantum_Milliseconds * TIME_CONVERSION__TO_MILLISECONDS);
302300

src/CLR/CorLib/corlib_native_System_Reflection_FieldInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -20,7 +20,6 @@ HRESULT Library_corlib_native_System_Reflection_FieldInfo::SetValue___VOID__OBJE
2020
CLR_RT_HeapBlock &srcVal = stack.Arg2();
2121
CLR_RT_HeapBlock val;
2222

23-
memset(&val, 0, sizeof(struct CLR_RT_HeapBlock));
2423
val.Assign(srcVal);
2524
CLR_RT_ProtectFromGC gc(val);
2625

src/CLR/CorLib/corlib_native_System_Reflection_RuntimeFieldInfo.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -86,8 +86,6 @@ HRESULT Library_corlib_native_System_Reflection_RuntimeFieldInfo::GetValue___OBJ
8686
CLR_RT_HeapBlock *obj;
8787
CLR_RT_HeapBlock dst;
8888

89-
memset(&dst, 0, sizeof(struct CLR_RT_HeapBlock));
90-
9189
NANOCLR_CHECK_HRESULT(Library_corlib_native_System_Reflection_FieldInfo::Initialize(stack, instFD, instTD, obj));
9290

9391
fd = instFD.m_target;

src/CLR/CorLib/corlib_native_System_Runtime_CompilerServices_RuntimeHelpers.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -145,8 +145,6 @@ HRESULT Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::
145145
CLR_RT_HeapBlock tmp;
146146
CLR_UINT32 *ptr = (CLR_UINT32 *)ptrDst;
147147

148-
memset(&tmp, 0, sizeof(struct CLR_RT_HeapBlock));
149-
150148
for (; lenSrc; lenSrc--, ptr++)
151149
{
152150
NANOCLR_CHECK_HRESULT(tmp.SetFloatIEEE754(*ptr));
@@ -161,8 +159,6 @@ HRESULT Library_corlib_native_System_Runtime_CompilerServices_RuntimeHelpers::
161159
CLR_RT_HeapBlock tmp;
162160
CLR_UINT64 *ptr = (CLR_UINT64 *)ptrDst;
163161

164-
memset(&tmp, 0, sizeof(struct CLR_RT_HeapBlock));
165-
166162
for (; lenSrc; lenSrc--, ptr++)
167163
{
168164
NANOCLR_CHECK_HRESULT(tmp.SetDoubleIEEE754(*ptr));

src/CLR/CorLib/corlib_native_System_String.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ HRESULT Library_corlib_native_System_String::_ctor___VOID__CHAR__I4(CLR_RT_Stack
206206
{
207207
CLR_RT_HeapBlock tmp;
208208

209-
memset(&tmp, 0, sizeof(struct CLR_RT_HeapBlock));
210209
tmp.SetObjectReference(NULL);
211210
CLR_RT_ProtectFromGC gc(tmp);
212211

@@ -865,7 +864,6 @@ HRESULT Library_corlib_native_System_String::ChangeCase(CLR_RT_StackFrame &stack
865864
CLR_RT_HeapBlock_Array *arrayTmp;
866865
CLR_RT_HeapBlock refTmp;
867866

868-
memset(&refTmp, 0, sizeof(struct CLR_RT_HeapBlock));
869867
refTmp.SetObjectReference(NULL);
870868
CLR_RT_ProtectFromGC gc(refTmp);
871869

@@ -907,7 +905,6 @@ HRESULT Library_corlib_native_System_String::Substring(CLR_RT_StackFrame &stack,
907905
CLR_RT_HeapBlock_Array *arrayTmp;
908906
CLR_RT_HeapBlock refTmp;
909907

910-
memset(&refTmp, 0, sizeof(struct CLR_RT_HeapBlock));
911908
refTmp.SetObjectReference(NULL);
912909
CLR_RT_ProtectFromGC gc(refTmp);
913910

@@ -949,7 +946,6 @@ HRESULT Library_corlib_native_System_String::Trim(
949946
CLR_RT_HeapBlock refTmp;
950947
CLR_RT_HeapBlock_Array *arrayTmp;
951948

952-
memset(&refTmp, 0, sizeof(struct CLR_RT_HeapBlock));
953949
refTmp.SetObjectReference(NULL);
954950
CLR_RT_ProtectFromGC gc(refTmp);
955951

@@ -1063,7 +1059,6 @@ HRESULT Library_corlib_native_System_String::Split(CLR_RT_StackFrame &stack, CLR
10631059
{
10641060
CLR_RT_HeapBlock refSrc;
10651061

1066-
memset(&refSrc, 0, sizeof(struct CLR_RT_HeapBlock));
10671062
refSrc.SetObjectReference(NULL);
10681063
CLR_RT_ProtectFromGC gc(refSrc);
10691064

src/CLR/CorLib/corlib_native_System_Threading_Interlocked.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright (c) .NET Foundation and Contributors
33
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
44
// See LICENSE file in the project root for full license information.
@@ -12,7 +12,6 @@ HRESULT Library_corlib_native_System_Threading_Interlocked::Increment___STATIC__
1212
NANOCLR_HEADER();
1313
{
1414
CLR_RT_HeapBlock heapLocation;
15-
memset(&heapLocation, 0, sizeof(struct CLR_RT_HeapBlock));
1615

1716
NANOCLR_CHECK_HRESULT(heapLocation.LoadFromReference(stack.Arg0()));
1817
signed int &location = heapLocation.NumericByRef().s4;
@@ -33,7 +32,6 @@ HRESULT Library_corlib_native_System_Threading_Interlocked::Decrement___STATIC__
3332
NANOCLR_HEADER();
3433
{
3534
CLR_RT_HeapBlock heapLocation;
36-
memset(&heapLocation, 0, sizeof(struct CLR_RT_HeapBlock));
3735

3836
NANOCLR_CHECK_HRESULT(heapLocation.LoadFromReference(stack.Arg0()));
3937
signed int &location = heapLocation.NumericByRef().s4;
@@ -55,7 +53,6 @@ HRESULT Library_corlib_native_System_Threading_Interlocked::Exchange___STATIC__I
5553
NANOCLR_HEADER();
5654
{
5755
CLR_RT_HeapBlock heapLocation;
58-
memset(&heapLocation, 0, sizeof(struct CLR_RT_HeapBlock));
5956

6057
NANOCLR_CHECK_HRESULT(heapLocation.LoadFromReference(stack.Arg0()));
6158
signed int &location = heapLocation.NumericByRef().s4;
@@ -79,7 +76,6 @@ HRESULT Library_corlib_native_System_Threading_Interlocked::CompareExchange___ST
7976
NANOCLR_HEADER();
8077
{
8178
CLR_RT_HeapBlock heapLocation;
82-
memset(&heapLocation, 0, sizeof(struct CLR_RT_HeapBlock));
8379

8480
NANOCLR_CHECK_HRESULT(heapLocation.LoadFromReference(stack.Arg0()));
8581
signed int &location = heapLocation.NumericByRef().s4;

src/CLR/CorLib/corlib_native_System_Threading_SpinWait.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ HRESULT Library_corlib_native_System_Threading_SpinWait::Spin(CLR_RT_StackFrame
4949
bool longRunning;
5050
bool eventResult = true;
5151

52-
memset(&hbTimeout, 0, sizeof(struct CLR_RT_HeapBlock));
53-
5452
if (isTimeSpan)
5553
{
5654
timeout = Library_corlib_native_System_TimeSpan::GetValuePtr(stack.Arg0());

src/CLR/CorLib/corlib_native_System_TimeSpan.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ HRESULT Library_corlib_native_System_TimeSpan::Compare___STATIC__I4__SystemTimeS
149149
CLR_RT_HeapBlock resLeft;
150150
CLR_RT_HeapBlock resRight;
151151

152-
memset(&resLeft, 0, sizeof(struct CLR_RT_HeapBlock));
153-
memset(&resRight, 0, sizeof(struct CLR_RT_HeapBlock));
154-
155152
pLeft = Library_corlib_native_System_TimeSpan::GetValuePtr(stack);
156153
FAULT_ON_NULL(pLeft);
154+
157155
pRight = Library_corlib_native_System_TimeSpan::GetValuePtr(stack.Arg1());
158156
FAULT_ON_NULL(pRight);
159157

0 commit comments

Comments
 (0)