mirror of
https://github.com/espressif/tlsf.git
synced 2025-11-16 04:24:45 +00:00
tlsf: move control_t to tlsf.c
- the control_t structure should not be available to the user so it was moved to tlsf.c. In addition bitfields are now used in control_t when possible which reduces the size of the structure from 56 bytes to 36 bytes. - fix an assert message to place it in the tlsf_assert - add comment about the index count log2 field in control_t
This commit is contained in:
3
tlsf.c
3
tlsf.c
@@ -629,7 +629,8 @@ static control_t* control_construct(control_t* control, size_t bytes)
|
||||
|
||||
|
||||
/* SL_INDEX_COUNT must be <= number of bits in sl_bitmap's storage type. */
|
||||
tlsf_assert(sizeof(unsigned int) * CHAR_BIT >= control->sl_index_count); //CHAR_BIT less than sl_index_count");
|
||||
tlsf_assert(sizeof(unsigned int) * CHAR_BIT >= control->sl_index_count
|
||||
&& "CHAR_BIT less than sl_index_count");
|
||||
|
||||
/* Ensure we've properly tuned our sizes. */
|
||||
tlsf_assert(ALIGN_SIZE == control->small_block_size / control->sl_index_count); //ALIGN_SIZE does not match");
|
||||
|
||||
@@ -93,24 +93,35 @@ typedef struct control_t
|
||||
/* Empty lists point at this block to indicate they are free. */
|
||||
block_header_t block_null;
|
||||
|
||||
/* Local parameter for the pool */
|
||||
unsigned int fl_index_count;
|
||||
unsigned int fl_index_shift;
|
||||
unsigned int fl_index_max;
|
||||
unsigned int sl_index_count;
|
||||
unsigned int sl_index_count_log2;
|
||||
unsigned int small_block_size;
|
||||
/* Local parameter for the pool. Given the maximum
|
||||
* value of each field, all the following parameters
|
||||
* can fit on 4 bytes when using bitfields
|
||||
*/
|
||||
unsigned int fl_index_count : 5; // 5 cumulated bits
|
||||
unsigned int fl_index_shift : 3; // 8 cumulated bits
|
||||
unsigned int fl_index_max : 6; // 14 cumulated bits
|
||||
unsigned int sl_index_count : 6; // 20 cumulated bits
|
||||
|
||||
/* log2 of number of linear subdivisions of block sizes. Larger
|
||||
** values require more memory in the control structure. Values of
|
||||
** 4 or 5 are typical.
|
||||
*/
|
||||
unsigned int sl_index_count_log2 : 3; // 23 cumulated bits
|
||||
unsigned int small_block_size : 8; // 31 cumulated bits
|
||||
|
||||
/* size of the metadata ( size of control block,
|
||||
* sl_bitmap and blocks )
|
||||
*/
|
||||
size_t size;
|
||||
|
||||
/* Bitmaps for free lists. */
|
||||
unsigned int fl_bitmap;
|
||||
unsigned int *sl_bitmap;
|
||||
unsigned int *sl_bitmap;
|
||||
|
||||
/* Head of free lists. */
|
||||
block_header_t** blocks;
|
||||
} control_t;
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user