Update tlsf.c

Unsigned fix from Chris McEvoy @ Velan Studios.
This commit is contained in:
Matt Conte
2020-03-29 09:55:11 -07:00
parent a1f743ffac
commit deff9ab509

12
tlsf.c
View File

@@ -590,12 +590,12 @@ static void remove_free_block(control_t* control, block_header_t* block, int fl,
/* If the new head is null, clear the bitmap. */
if (next == &control->block_null)
{
control->sl_bitmap[fl] &= ~(1 << sl);
control->sl_bitmap[fl] &= ~(1U << sl);
/* If the second bitmap is now empty, clear the fl bitmap. */
if (!control->sl_bitmap[fl])
{
control->fl_bitmap &= ~(1 << fl);
control->fl_bitmap &= ~(1U << fl);
}
}
}
@@ -618,8 +618,8 @@ static void insert_free_block(control_t* control, block_header_t* block, int fl,
** and second-level bitmaps appropriately.
*/
control->blocks[fl][sl] = block;
control->fl_bitmap |= (1 << fl);
control->sl_bitmap[fl] |= (1 << sl);
control->fl_bitmap |= (1U << fl);
control->sl_bitmap[fl] |= (1U << sl);
}
/* Remove a given block from the free list. */
@@ -853,9 +853,9 @@ int tlsf_check(tlsf_t tlsf)
{
for (j = 0; j < SL_INDEX_COUNT; ++j)
{
const int fl_map = control->fl_bitmap & (1 << i);
const int fl_map = control->fl_bitmap & (1U << i);
const int sl_list = control->sl_bitmap[i];
const int sl_map = sl_list & (1 << j);
const int sl_map = sl_list & (1U << j);
const block_header_t* block = control->blocks[i][j];
/* Check that first- and second-level lists agree. */