Guest User

Untitled

a guest
Feb 20th, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uint32_t get_index(uint32_t addr, uint32_t* offset)
  2. {
  3.     addr = addr / PAGESIZE;
  4.     *offset = addr % 32;
  5.     return addr / 32;
  6. }
  7.  
  8. void pfree(void* addr)
  9. {
  10.     uint32_t offset;
  11.     uint32_t index = get_index((uint32_t) addr, &offset);
  12.     bitmap[index] &= ~(1 << offset);
  13.     free_memory += 0x1000;
  14. }
  15.  
  16. static void use(void* addr)
  17. {
  18.     uint32_t offset;
  19.     uint32_t index = get_index((uint32_t) addr, &offset);
  20.     bitmap[index] |= (1 << offset);
  21.     free_memory -= 0x1000;
  22. }
  23.  
  24. static uint32_t is_free(void* addr)
  25. {
  26.     uint32_t offset;
  27.     uint32_t index = get_index((uint32_t) addr, &offset);
  28.     return (bitmap[index] & (1 << offset));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment