MonkOS  v0.1
A simple 64-bit operating system (x86_64)
heap.h File Reference

A simple heap memory manager. More...

#include <core.h>
#include <kernel/mem/paging.h>

Go to the source code of this file.

Functions

heap_t * heap_create (pagetable_t *pt, void *vaddr, uint64_t maxpages)
 Create a new heap from which to allocate virtual memory. More...
 
void heap_destroy (heap_t *heap)
 Destroy a heap, returning its memory to page table. More...
 
void * heap_alloc (heap_t *heap, uint64_t size)
 Allocate memory from a heap. More...
 
void heap_free (heap_t *heap, void *ptr)
 Free memory previously allocated with heap_alloc. More...
 

Detailed Description

A simple heap memory manager.

Definition in file heap.h.

Function Documentation

heap_t* heap_create ( pagetable_t pt,
void *  vaddr,
uint64_t  maxpages 
)

Create a new heap from which to allocate virtual memory.

Parameters
[in]ptThe page table from which virtual memory is to be allocated.
[in]vaddrThe virtual address of the first byte to use for the heap.
[in]maxpagesThe maximum number of pages that the heap will grow to fill.
Returns
A pointer to a the created heap structure.

Definition at line 61 of file heap.c.

Referenced by cmd_test_heap().

void heap_destroy ( heap_t *  heap)

Destroy a heap, returning its memory to page table.

Parameters
[in]heapThe heap to be destroyed.

Definition at line 90 of file heap.c.

Referenced by cmd_test_heap().

void* heap_alloc ( heap_t *  heap,
uint64_t  size 
)

Allocate memory from a heap.

Parameters
[in]heapThe heap from which to allocate the memory.
[in]sizeThe size, in bytes, of the allocation.
Returns
A pointer to a the allocated memory.

Definition at line 239 of file heap.c.

Referenced by cmd_test_heap().

void heap_free ( heap_t *  heap,
void *  ptr 
)

Free memory previously allocated with heap_alloc.

Parameters
[in]heapThe heap from which the memory was allocated.
[in]ptrA pointer to the memory that was allocated.

Definition at line 319 of file heap.c.

Referenced by cmd_test_heap().