Fix alloc_count_continuous calculation
This commit is contained in:
parent
acee4b5c37
commit
5b5e6d3ee6
@ -515,29 +515,27 @@ size_t alloc_count_free(void* pool) {
|
|||||||
size_t alloc_count_continuous(void* pool) {
|
size_t alloc_count_continuous(void* pool) {
|
||||||
(void) pool;
|
(void) pool;
|
||||||
|
|
||||||
size_t largest_block = 0;
|
size_t contiguous_free = 0;
|
||||||
|
size_t most_contiguous = 0;
|
||||||
|
|
||||||
size_t free_bits = 0;
|
|
||||||
for(size_t i = 0; i < pool_header.block_count; ++i) {
|
for(size_t i = 0; i < pool_header.block_count; ++i) {
|
||||||
uint8_t t = pool_header.block_usage[i];
|
uint8_t t = pool_header.block_usage[i];
|
||||||
|
|
||||||
for(int i = 7; i >= 0; --i) {
|
for(int i = 7; i >= 0; --i) {
|
||||||
bool bitset = (t & (1 << i));
|
bool bitset = (t & (1 << i));
|
||||||
if(!bitset) {
|
if(!bitset) {
|
||||||
++free_bits;
|
++contiguous_free;
|
||||||
} else {
|
} else {
|
||||||
free_bits = 0;
|
if(contiguous_free > most_contiguous) {
|
||||||
size_t free_size = free_bits * 256;
|
most_contiguous = contiguous_free;
|
||||||
if(free_size > largest_block) {
|
|
||||||
largest_block = free_size;
|
|
||||||
}
|
}
|
||||||
|
contiguous_free = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(free_bits && (free_bits * 256) > largest_block) {
|
if(contiguous_free > most_contiguous) {
|
||||||
largest_block = (free_bits * 256);
|
most_contiguous = contiguous_free;
|
||||||
}
|
}
|
||||||
printf("LARGEST: %d\n", largest_block);
|
return most_contiguous * 256;
|
||||||
return largest_block;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user