AKOS  v1.0.0
Documentation
Loading...
Searching...
No Matches
memory.c File Reference

Fixed-size heap allocator implementation. More...

#include "config.h"
#include "memory.h"
#include "core.h"
Include dependency graph for memory.c:

Go to the source code of this file.

Macros

#define ALIGNMENT   ((size_t)4U)
#define MEM_ALIGN(size)
#define MIN_SIZE_TO_SPLIT   ((size_t)8U)
#define SIZE_OF_BLOCK_HEADER   ((size_t)MEM_ALIGN(sizeof(mem_blk_header_t)))

Functions

void * akos_memory_malloc (size_t size)
 Allocate block from heap.
void akos_memory_free (void *p_addr)
 Free previously allocated heap block.

Detailed Description

Fixed-size heap allocator implementation.

Author
AKOS contributors
Date
2026/05/08

Definition in file memory.c.

Macro Definition Documentation

◆ ALIGNMENT

#define ALIGNMENT   ((size_t)4U)

Definition at line 29 of file memory.c.

◆ MEM_ALIGN

#define MEM_ALIGN ( size)
Value:
(size_t)(((size) + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1))

Definition at line 30 of file memory.c.

◆ MIN_SIZE_TO_SPLIT

#define MIN_SIZE_TO_SPLIT   ((size_t)8U)

Definition at line 31 of file memory.c.

◆ SIZE_OF_BLOCK_HEADER

#define SIZE_OF_BLOCK_HEADER   ((size_t)MEM_ALIGN(sizeof(mem_blk_header_t)))

Definition at line 32 of file memory.c.

Function Documentation

◆ akos_memory_free()

void akos_memory_free ( void * p_addr)

Free previously allocated heap block.

Free previously allocated memory block.

Parameters
p_addrPointer returned by akos_memory_malloc.

Definition at line 139 of file memory.c.

◆ akos_memory_malloc()

void * akos_memory_malloc ( size_t size)

Allocate block from heap.

Allocate memory from OS heap.

Parameters
sizeRequested size in bytes.
Returns
Pointer to payload, or NULL if no suitable block.

Definition at line 65 of file memory.c.