GitOS
Operating system exercise
Loading...
Searching...
No Matches
kheap.h File Reference
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Functions

int kheap_init (void *start_address, uint32_t size)
 Initializes kernel heap.
 
void * kmalloc (size_t size)
 Allocates specified size in heap.
 
void * kzalloc (size_t size)
 Allocated specified size in heap and zeroes it.
 
void kfree (void *ptr)
 Frees specified pointer.
 

Function Documentation

◆ kfree()

void kfree ( void *  ptr)

Frees specified pointer.

Parameters
ptrPointer to free

References heap_free(), and kernel_heap.

◆ kheap_init()

int kheap_init ( void *  start_address,
uint32_t  size 
)

Initializes kernel heap.

Parameters
start_addressStarting address for heap allocation
sizeSize of heap in bytes
Returns
int Status

References heap_table::entries, HEAP_BLOCK_SIZE, heap_create(), HEAP_TABLE_ADDRESS, kernel_heap, kernel_heap_table, size, start_address, and heap_table::total.

◆ kmalloc()

void * kmalloc ( size_t  size)

Allocates specified size in heap.

Parameters
sizeRequested allocation size
Returns
void* Pointer to allocated memory, 0 if errored

References heap_malloc(), kernel_heap, and size.

◆ kzalloc()

void * kzalloc ( size_t  size)

Allocated specified size in heap and zeroes it.

Parameters
sizeRequested allocation swize
Returns
void* Pointer to allocated memory, 0 if errored

References kmalloc(), memset(), and size.