Kernelite 0.1.0
Kernelite is a minimalist, educational operating system kernel built from scratch. The project aims to recreate core components of the Linux architecture to explore the fundamentals of operating system design and hardware-software interaction.
Loading...
Searching...
No Matches
Functions
kalloc.h File Reference

Kernel heap allocator for variable-sized dynamic memory. More...

#include <stddef.h>
Include dependency graph for kalloc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * kmalloc (size_t size)
 Allocates a block of memory from the kernel heap.
 
void kfree (void *ptr)
 Frees a block of memory previously returned by kmalloc().
 

Detailed Description

Kernel heap allocator for variable-sized dynamic memory.

This module provides the kernel-side dynamic memory API. It hands out variable-sized allocations from the kernel heap and returns them for reuse, layering on top of the physical page allocator.

Author
Abhin Parekadan Jose
Date
2026-07-05

Function Documentation

◆ kfree()

void kfree ( void *  ptr)

Frees a block of memory previously returned by kmalloc().

Returns the block starting at ptr to the kernel heap so it can be reused. Passing NULL is a no-op.

Parameters
ptrPointer to the block to free, as returned by kmalloc().

◆ kmalloc()

void * kmalloc ( size_t  size)

Allocates a block of memory from the kernel heap.

Reserves at least size bytes of contiguous memory for the caller.

Parameters
sizeThe number of bytes to allocate.
Returns
void* Pointer to the allocated block, or NULL if the request could not be satisfied.