]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/MemMang/heap_5.c
7f4e3c4a92ca14ada4a08879c87d403ea795e615
[freertos] / FreeRTOS / Source / portable / MemMang / heap_5.c
1 /*\r
2     FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
12 \r
13         ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18         ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40         the FAQ page "My application does not run, what could be wrong?".  Have you\r
41         defined configASSERT()?\r
42 \r
43         http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44         embedded software for free we request you assist our global community by\r
45         participating in the support forum.\r
46 \r
47         http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48         be as productive as possible as early as possible.  Now you can receive\r
49         FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50         Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 /*\r
71  * A sample implementation of pvPortMalloc() that allows the heap to be defined\r
72  * across multiple non-contigous blocks and combines (coalescences) adjacent\r
73  * memory blocks as they are freed.\r
74  *\r
75  * See heap_1.c, heap_2.c, heap_3.c and heap_4.c for alternative\r
76  * implementations, and the memory management pages of http://www.FreeRTOS.org\r
77  * for more information.\r
78  *\r
79  * Usage notes:\r
80  *\r
81  * vPortDefineHeapRegions() ***must*** be called before pvPortMalloc().\r
82  * pvPortMalloc() will be called if any task objects (tasks, queues, event\r
83  * groups, etc.) are created, therefore vPortDefineHeapRegions() ***must*** be\r
84  * called before any other objects are defined.\r
85  *\r
86  * vPortDefineHeapRegions() takes a single parameter.  The parameter is an array\r
87  * of HeapRegion_t structures.  HeapRegion_t is defined in portable.h as\r
88  *\r
89  * typedef struct HeapRegion\r
90  * {\r
91  *      uint8_t *pucStartAddress; << Start address of a block of memory that will be part of the heap.\r
92  *      size_t xSizeInBytes;      << Size of the block of memory.\r
93  * } HeapRegion_t;\r
94  *\r
95  * The array is terminated using a NULL zero sized region definition, and the\r
96  * memory regions defined in the array ***must*** appear in address order from\r
97  * low address to high address.  So the following is a valid example of how\r
98  * to use the function.\r
99  *\r
100  * HeapRegion_t xHeapRegions[] =\r
101  * {\r
102  *      { ( uint8_t * ) 0x80000000UL, 0x10000 }, << Defines a block of 0x10000 bytes starting at address 0x80000000\r
103  *      { ( uint8_t * ) 0x90000000UL, 0xa0000 }, << Defines a block of 0xa0000 bytes starting at address of 0x90000000\r
104  *      { NULL, 0 }                << Terminates the array.\r
105  * };\r
106  *\r
107  * vPortDefineHeapRegions( xHeapRegions ); << Pass the array into vPortDefineHeapRegions().\r
108  *\r
109  * Note 0x80000000 is the lower address so appears in the array first.\r
110  *\r
111  */\r
112 #include <stdlib.h>\r
113 \r
114 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
115 all the API functions to use the MPU wrappers.  That should only be done when\r
116 task.h is included from an application file. */\r
117 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
118 \r
119 #include "FreeRTOS.h"\r
120 #include "task.h"\r
121 \r
122 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
123 \r
124 /* Block sizes must not get too small. */\r
125 #define heapMINIMUM_BLOCK_SIZE  ( ( size_t ) ( uxHeapStructSize << 1 ) )\r
126 \r
127 /* Assumes 8bit bytes! */\r
128 #define heapBITS_PER_BYTE               ( ( size_t ) 8 )\r
129 \r
130 /* Define the linked list structure.  This is used to link free blocks in order\r
131 of their memory address. */\r
132 typedef struct A_BLOCK_LINK\r
133 {\r
134         struct A_BLOCK_LINK *pxNextFreeBlock;   /*<< The next free block in the list. */\r
135         size_t xBlockSize;                                              /*<< The size of the free block. */\r
136 } BlockLink_t;\r
137 \r
138 /*-----------------------------------------------------------*/\r
139 \r
140 /*\r
141  * Inserts a block of memory that is being freed into the correct position in\r
142  * the list of free memory blocks.  The block being freed will be merged with\r
143  * the block in front it and/or the block behind it if the memory blocks are\r
144  * adjacent to each other.\r
145  */\r
146 static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert );\r
147 \r
148 /*-----------------------------------------------------------*/\r
149 \r
150 /* The size of the structure placed at the beginning of each allocated memory\r
151 block must by correctly byte aligned. */\r
152 static const uint32_t uxHeapStructSize  = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );\r
153 \r
154 /* Create a couple of list links to mark the start and end of the list. */\r
155 static BlockLink_t xStart, *pxEnd = NULL;\r
156 \r
157 /* Keeps track of the number of free bytes remaining, but says nothing about\r
158 fragmentation. */\r
159 static size_t xFreeBytesRemaining = 0;\r
160 static size_t xMinimumEverFreeBytesRemaining = 0;\r
161 \r
162 /* Gets set to the top bit of an size_t type.  When this bit in the xBlockSize\r
163 member of an BlockLink_t structure is set then the block belongs to the\r
164 application.  When the bit is free the block is still part of the free heap\r
165 space. */\r
166 static size_t xBlockAllocatedBit = 0;\r
167 \r
168 /*-----------------------------------------------------------*/\r
169 \r
170 void *pvPortMalloc( size_t xWantedSize )\r
171 {\r
172 BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;\r
173 void *pvReturn = NULL;\r
174 \r
175         /* The heap must be initialised before the first call to\r
176         prvPortMalloc(). */\r
177         configASSERT( pxEnd );\r
178 \r
179         vTaskSuspendAll();\r
180         {\r
181                 /* Check the requested block size is not so large that the top bit is\r
182                 set.  The top bit of the block size member of the BlockLink_t structure\r
183                 is used to determine who owns the block - the application or the\r
184                 kernel, so it must be free. */\r
185                 if( ( xWantedSize & xBlockAllocatedBit ) == 0 )\r
186                 {\r
187                         /* The wanted size is increased so it can contain a BlockLink_t\r
188                         structure in addition to the requested amount of bytes. */\r
189                         if( xWantedSize > 0 )\r
190                         {\r
191                                 xWantedSize += uxHeapStructSize;\r
192 \r
193                                 /* Ensure that blocks are always aligned to the required number\r
194                                 of bytes. */\r
195                                 if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )\r
196                                 {\r
197                                         /* Byte alignment required. */\r
198                                         xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );\r
199                                 }\r
200                                 else\r
201                                 {\r
202                                         mtCOVERAGE_TEST_MARKER();\r
203                                 }\r
204                         }\r
205                         else\r
206                         {\r
207                                 mtCOVERAGE_TEST_MARKER();\r
208                         }\r
209 \r
210                         if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )\r
211                         {\r
212                                 /* Traverse the list from the start     (lowest address) block until\r
213                                 one     of adequate size is found. */\r
214                                 pxPreviousBlock = &xStart;\r
215                                 pxBlock = xStart.pxNextFreeBlock;\r
216                                 while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )\r
217                                 {\r
218                                         pxPreviousBlock = pxBlock;\r
219                                         pxBlock = pxBlock->pxNextFreeBlock;\r
220                                 }\r
221 \r
222                                 /* If the end marker was reached then a block of adequate size\r
223                                 was     not found. */\r
224                                 if( pxBlock != pxEnd )\r
225                                 {\r
226                                         /* Return the memory space pointed to - jumping over the\r
227                                         BlockLink_t structure at its start. */\r
228                                         pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + uxHeapStructSize );\r
229 \r
230                                         /* This block is being returned for use so must be taken out\r
231                                         of the list of free blocks. */\r
232                                         pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;\r
233 \r
234                                         /* If the block is larger than required it can be split into\r
235                                         two. */\r
236                                         if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )\r
237                                         {\r
238                                                 /* This block is to be split into two.  Create a new\r
239                                                 block following the number of bytes requested. The void\r
240                                                 cast is used to prevent byte alignment warnings from the\r
241                                                 compiler. */\r
242                                                 pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r
243 \r
244                                                 /* Calculate the sizes of two blocks split from the\r
245                                                 single block. */\r
246                                                 pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;\r
247                                                 pxBlock->xBlockSize = xWantedSize;\r
248 \r
249                                                 /* Insert the new block into the list of free blocks. */\r
250                                                 prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r
251                                         }\r
252                                         else\r
253                                         {\r
254                                                 mtCOVERAGE_TEST_MARKER();\r
255                                         }\r
256 \r
257                                         xFreeBytesRemaining -= pxBlock->xBlockSize;\r
258 \r
259                                         if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )\r
260                                         {\r
261                                                 xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;\r
262                                         }\r
263                                         else\r
264                                         {\r
265                                                 mtCOVERAGE_TEST_MARKER();\r
266                                         }\r
267 \r
268                                         /* The block is being returned - it is allocated and owned\r
269                                         by the application and has no "next" block. */\r
270                                         pxBlock->xBlockSize |= xBlockAllocatedBit;\r
271                                         pxBlock->pxNextFreeBlock = NULL;\r
272                                 }\r
273                                 else\r
274                                 {\r
275                                         mtCOVERAGE_TEST_MARKER();\r
276                                 }\r
277                         }\r
278                         else\r
279                         {\r
280                                 mtCOVERAGE_TEST_MARKER();\r
281                         }\r
282                 }\r
283                 else\r
284                 {\r
285                         mtCOVERAGE_TEST_MARKER();\r
286                 }\r
287 \r
288                 traceMALLOC( pvReturn, xWantedSize );\r
289         }\r
290         ( void ) xTaskResumeAll();\r
291 \r
292         #if( configUSE_MALLOC_FAILED_HOOK == 1 )\r
293         {\r
294                 if( pvReturn == NULL )\r
295                 {\r
296                         extern void vApplicationMallocFailedHook( void );\r
297                         vApplicationMallocFailedHook();\r
298                 }\r
299                 else\r
300                 {\r
301                         mtCOVERAGE_TEST_MARKER();\r
302                 }\r
303         }\r
304         #endif\r
305 \r
306         return pvReturn;\r
307 }\r
308 /*-----------------------------------------------------------*/\r
309 \r
310 void vPortFree( void *pv )\r
311 {\r
312 uint8_t *puc = ( uint8_t * ) pv;\r
313 BlockLink_t *pxLink;\r
314 \r
315         if( pv != NULL )\r
316         {\r
317                 /* The memory being freed will have an BlockLink_t structure immediately\r
318                 before it. */\r
319                 puc -= uxHeapStructSize;\r
320 \r
321                 /* This casting is to keep the compiler from issuing warnings. */\r
322                 pxLink = ( void * ) puc;\r
323 \r
324                 /* Check the block is actually allocated. */\r
325                 configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );\r
326                 configASSERT( pxLink->pxNextFreeBlock == NULL );\r
327 \r
328                 if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 )\r
329                 {\r
330                         if( pxLink->pxNextFreeBlock == NULL )\r
331                         {\r
332                                 /* The block is being returned to the heap - it is no longer\r
333                                 allocated. */\r
334                                 pxLink->xBlockSize &= ~xBlockAllocatedBit;\r
335 \r
336                                 vTaskSuspendAll();\r
337                                 {\r
338                                         /* Add this block to the list of free blocks. */\r
339                                         xFreeBytesRemaining += pxLink->xBlockSize;\r
340                                         traceFREE( pv, pxLink->xBlockSize );\r
341                                         prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );\r
342                                 }\r
343                                 ( void ) xTaskResumeAll();\r
344                         }\r
345                         else\r
346                         {\r
347                                 mtCOVERAGE_TEST_MARKER();\r
348                         }\r
349                 }\r
350                 else\r
351                 {\r
352                         mtCOVERAGE_TEST_MARKER();\r
353                 }\r
354         }\r
355 }\r
356 /*-----------------------------------------------------------*/\r
357 \r
358 size_t xPortGetFreeHeapSize( void )\r
359 {\r
360         return xFreeBytesRemaining;\r
361 }\r
362 /*-----------------------------------------------------------*/\r
363 \r
364 size_t xPortGetMinimumEverFreeHeapSize( void )\r
365 {\r
366         return xMinimumEverFreeBytesRemaining;\r
367 }\r
368 /*-----------------------------------------------------------*/\r
369 \r
370 static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert )\r
371 {\r
372 BlockLink_t *pxIterator;\r
373 uint8_t *puc;\r
374 \r
375         /* Iterate through the list until a block is found that has a higher address\r
376         than the block being inserted. */\r
377         for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock )\r
378         {\r
379                 /* Nothing to do here, just iterate to the right position. */\r
380         }\r
381 \r
382         /* Do the block being inserted, and the block it is being inserted after\r
383         make a contiguous block of memory? */\r
384         puc = ( uint8_t * ) pxIterator;\r
385         if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert )\r
386         {\r
387                 pxIterator->xBlockSize += pxBlockToInsert->xBlockSize;\r
388                 pxBlockToInsert = pxIterator;\r
389         }\r
390         else\r
391         {\r
392                 mtCOVERAGE_TEST_MARKER();\r
393         }\r
394 \r
395         /* Do the block being inserted, and the block it is being inserted before\r
396         make a contiguous block of memory? */\r
397         puc = ( uint8_t * ) pxBlockToInsert;\r
398         if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock )\r
399         {\r
400                 if( pxIterator->pxNextFreeBlock != pxEnd )\r
401                 {\r
402                         /* Form one big block from the two blocks. */\r
403                         pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize;\r
404                         pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock;\r
405                 }\r
406                 else\r
407                 {\r
408                         pxBlockToInsert->pxNextFreeBlock = pxEnd;\r
409                 }\r
410         }\r
411         else\r
412         {\r
413                 pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;\r
414         }\r
415 \r
416         /* If the block being inserted plugged a gab, so was merged with the block\r
417         before and the block after, then it's pxNextFreeBlock pointer will have\r
418         already been set, and should not be set here as that would make it point\r
419         to itself. */\r
420         if( pxIterator != pxBlockToInsert )\r
421         {\r
422                 pxIterator->pxNextFreeBlock = pxBlockToInsert;\r
423         }\r
424         else\r
425         {\r
426                 mtCOVERAGE_TEST_MARKER();\r
427         }\r
428 }\r
429 /*-----------------------------------------------------------*/\r
430 \r
431 void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions )\r
432 {\r
433 BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock;\r
434 uint8_t *pucAlignedHeap;\r
435 size_t xTotalRegionSize, xTotalHeapSize = 0;\r
436 BaseType_t xDefinedRegions = 0;\r
437 uint32_t ulAddress;\r
438 const HeapRegion_t *pxHeapRegion;\r
439 \r
440         /* Can only call once! */\r
441         configASSERT( pxEnd == NULL );\r
442 \r
443         pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );\r
444 \r
445         while( pxHeapRegion->xSizeInBytes > 0 )\r
446         {\r
447                 xTotalRegionSize = pxHeapRegion->xSizeInBytes;\r
448 \r
449                 /* Ensure the heap region starts on a correctly aligned boundary. */\r
450                 ulAddress = ( uint32_t ) pxHeapRegion->pucStartAddress;\r
451                 if( ( ulAddress & portBYTE_ALIGNMENT_MASK ) != 0 )\r
452                 {\r
453                         ulAddress += ( portBYTE_ALIGNMENT - 1 );\r
454                         ulAddress &= ~portBYTE_ALIGNMENT_MASK;\r
455 \r
456                         /* Adjust the size for the bytes lost to alignment. */\r
457                         xTotalRegionSize -= ulAddress - ( uint32_t ) pxHeapRegion->pucStartAddress;\r
458                 }\r
459 \r
460                 pucAlignedHeap = ( uint8_t * ) ulAddress;\r
461 \r
462                 /* Set xStart if it has not already been set. */\r
463                 if( xDefinedRegions == 0 )\r
464                 {\r
465                         /* xStart is used to hold a pointer to the first item in the list of\r
466                         free blocks.  The void cast is used to prevent compiler warnings. */\r
467                         xStart.pxNextFreeBlock = ( BlockLink_t * ) pucAlignedHeap;\r
468                         xStart.xBlockSize = ( size_t ) 0;\r
469                 }\r
470                 else\r
471                 {\r
472                         /* Should only get here if one region has already been added to the\r
473                         heap. */\r
474                         configASSERT( pxEnd != NULL );\r
475 \r
476                         /* Check blocks are passed in with increasing start addresses. */\r
477                         configASSERT( ulAddress > ( uint32_t ) pxEnd );\r
478                 }\r
479 \r
480                 /* Remember the location of the end marker in the previous region, if\r
481                 any. */\r
482                 pxPreviousFreeBlock = pxEnd;\r
483 \r
484                 /* pxEnd is used to mark the end of the list of free blocks and is\r
485                 inserted at the end of the region space. */\r
486                 ulAddress = ( ( uint32_t ) pucAlignedHeap ) + xTotalRegionSize;\r
487                 ulAddress -= uxHeapStructSize;\r
488                 ulAddress &= ~portBYTE_ALIGNMENT_MASK;\r
489                 pxEnd = ( BlockLink_t * ) ulAddress;\r
490                 pxEnd->xBlockSize = 0;\r
491                 pxEnd->pxNextFreeBlock = NULL;\r
492 \r
493                 /* To start with there is a single free block in this region that is\r
494                 sized to take up the entire heap region minus the space taken by the\r
495                 free block structure. */\r
496                 pxFirstFreeBlockInRegion = ( BlockLink_t * ) pucAlignedHeap;\r
497                 pxFirstFreeBlockInRegion->xBlockSize = ulAddress - ( uint32_t ) pxFirstFreeBlockInRegion;\r
498                 pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd;\r
499 \r
500                 /* If this is not the first region that makes up the entire heap space\r
501                 then link the previous region to this region. */\r
502                 if( pxPreviousFreeBlock != NULL )\r
503                 {\r
504                         pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion;\r
505                 }\r
506 \r
507                 xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize;\r
508 \r
509                 /* Move onto the next HeapRegion_t structure. */\r
510                 xDefinedRegions++;\r
511                 pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );\r
512         }\r
513 \r
514         xMinimumEverFreeBytesRemaining = xTotalHeapSize;\r
515         xFreeBytesRemaining = xTotalHeapSize;\r
516 \r
517         /* Check something was actually defined before it is accessed. */\r
518         configASSERT( xTotalHeapSize );\r
519 \r
520         /* Work out the position of the top bit in a size_t variable. */\r
521         xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );\r
522 }\r
523 \r