MORE REFACTOR

multiboot
E. Almqvist 3 years ago
parent e896574001
commit 4b9f3bf5bd
  1. 8
      kernel/memory.c

@ -71,20 +71,16 @@ bool check_block_range(uint start, uint end) {
} }
int find_free(uint block_count) { int find_free(uint block_count) {
int lowerb = -1; // if this function returns -1
// then it has failed.
// Loop through bitmap starting at last_block // Loop through bitmap starting at last_block
for( uint lower = last_block; lower < MAX_BLOCK_COUNT - block_count; lower++ ) { for( uint lower = last_block; lower < MAX_BLOCK_COUNT - block_count; lower++ ) {
bool range_is_free = check_block_range(lower, lower + block_count); bool range_is_free = check_block_range(lower, lower + block_count);
if(range_is_free == true) { // if range is free if(range_is_free == true) { // if range is free
lowerb = (int)lower; return lower;
break; // then stop searching
} }
} }
return lowerb; // return the lower block index return -1; // return the lower block index
} }
void pm_malloc_range(ulong start, ulong end, bool force) { void pm_malloc_range(ulong start, ulong end, bool force) {

Loading…
Cancel
Save