File tree 2 files changed +48
-12
lines changed
2 files changed +48
-12
lines changed Original file line number Diff line number Diff line change @@ -159,13 +159,31 @@ void * pvPortMalloc( size_t xWantedSize )
159
159
if ( xWantedSize > 0 )
160
160
{
161
161
/* The wanted size must be increased so it can contain a BlockLink_t
162
- * structure in addition to the requested amount of bytes. Some
163
- * additional increment may also be needed for alignment. */
164
- xAdditionalRequiredSize = xHeapStructSize + portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK );
165
-
166
- if ( heapADD_WILL_OVERFLOW ( xWantedSize , xAdditionalRequiredSize ) == 0 )
162
+ * structure in addition to the requested amount of bytes. */
163
+ if ( heapADD_WILL_OVERFLOW ( xWantedSize , xHeapStructSize ) == 0 )
167
164
{
168
- xWantedSize += xAdditionalRequiredSize ;
165
+ xWantedSize += xHeapStructSize ;
166
+
167
+ /* Ensure that blocks are always aligned to the required number
168
+ * of bytes. */
169
+ if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
170
+ {
171
+ /* Byte alignment required. */
172
+ xAdditionalRequiredSize = portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK );
173
+
174
+ if ( heapADD_WILL_OVERFLOW ( xWantedSize , xAdditionalRequiredSize ) == 0 )
175
+ {
176
+ xWantedSize += xAdditionalRequiredSize ;
177
+ }
178
+ else
179
+ {
180
+ xWantedSize = 0 ;
181
+ }
182
+ }
183
+ else
184
+ {
185
+ mtCOVERAGE_TEST_MARKER ();
186
+ }
169
187
}
170
188
else
171
189
{
Original file line number Diff line number Diff line change @@ -170,13 +170,31 @@ void * pvPortMalloc( size_t xWantedSize )
170
170
if ( xWantedSize > 0 )
171
171
{
172
172
/* The wanted size must be increased so it can contain a BlockLink_t
173
- * structure in addition to the requested amount of bytes. Some
174
- * additional increment may also be needed for alignment. */
175
- xAdditionalRequiredSize = xHeapStructSize + portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK );
176
-
177
- if ( heapADD_WILL_OVERFLOW ( xWantedSize , xAdditionalRequiredSize ) == 0 )
173
+ * structure in addition to the requested amount of bytes. */
174
+ if ( heapADD_WILL_OVERFLOW ( xWantedSize , xHeapStructSize ) == 0 )
178
175
{
179
- xWantedSize += xAdditionalRequiredSize ;
176
+ xWantedSize += xHeapStructSize ;
177
+
178
+ /* Ensure that blocks are always aligned to the required number
179
+ * of bytes. */
180
+ if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
181
+ {
182
+ /* Byte alignment required. */
183
+ xAdditionalRequiredSize = portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK );
184
+
185
+ if ( heapADD_WILL_OVERFLOW ( xWantedSize , xAdditionalRequiredSize ) == 0 )
186
+ {
187
+ xWantedSize += xAdditionalRequiredSize ;
188
+ }
189
+ else
190
+ {
191
+ xWantedSize = 0 ;
192
+ }
193
+ }
194
+ else
195
+ {
196
+ mtCOVERAGE_TEST_MARKER ();
197
+ }
180
198
}
181
199
else
182
200
{
You can’t perform that action at this time.
0 commit comments