Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint32_t get_index(uint32_t addr, uint32_t* offset)
- {
- addr = addr / PAGESIZE;
- *offset = addr % 32;
- return addr / 32;
- }
- void pfree(void* addr)
- {
- uint32_t offset;
- uint32_t index = get_index((uint32_t) addr, &offset);
- bitmap[index] &= ~(1 << offset);
- free_memory += 0x1000;
- }
- static void use(void* addr)
- {
- uint32_t offset;
- uint32_t index = get_index((uint32_t) addr, &offset);
- bitmap[index] |= (1 << offset);
- free_memory -= 0x1000;
- }
- static uint32_t is_free(void* addr)
- {
- uint32_t offset;
- uint32_t index = get_index((uint32_t) addr, &offset);
- return (bitmap[index] & (1 << offset));
- }
Advertisement
Add Comment
Please, Sign In to add comment