kmalloc.h 632 B

123456789101112131415161718
  1. /* Kernel heap allocator (kmalloc/kfree) on top of the page-frame allocator.
  2. *
  3. * Power-of-two segregated free lists:
  4. * - small allocations (<= one page) come from size-class free lists, which
  5. * are refilled by carving whole pages from the frame allocator.
  6. * - large allocations (> one page) allocate contiguous pages directly.
  7. *
  8. * Each block carries a 4-byte header immediately before the returned pointer;
  9. * it stores the block size (so kfree knows which free list / how many pages).
  10. */
  11. #ifndef KMALLOC_H
  12. #define KMALLOC_H
  13. void *kmalloc(unsigned int size);
  14. void kfree(void *ptr);
  15. void kmalloc_init(void);
  16. #endif