SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions | Variables
smalloc.c File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <types.h>
#include "smalloc.h"
Include dependency graph for smalloc.c:

Functions

int32_t smalloc_init (uint32_t p_heap_head, uint32_t n_heap_size)
 Initialize the simple malloc library with the specified heap parameters.
 
void * smalloc (uint32_t num_bytes)
 Allocate a block of memory from the heap with the specified size.
 
void * srealloc (void *p, uint32_t num_bytes)
 Reallocate a block of memory with the specified new size.
 
void sfree (void *p)
 Free the memory block pointed to by the specified pointer.
 

Variables

static struct alloc_struct_t boot_heap_head boot_heap_tail
 

Function Documentation

◆ sfree()

void sfree ( void *  p)

Free the memory block pointed to by the specified pointer.

Parameters
pThe pointer to the memory block to free.

◆ smalloc()

void * smalloc ( uint32_t  num_bytes)

Allocate a block of memory from the heap with the specified size.

Parameters
num_bytesThe number of bytes to allocate.
Returns
A pointer to the allocated memory block, or NULL if allocation fails.

◆ smalloc_init()

int32_t smalloc_init ( uint32_t  p_heap_head,
uint32_t  n_heap_size 
)

Initialize the simple malloc library with the specified heap parameters.

Parameters
p_heap_headThe starting address of the heap.
n_heap_sizeThe size of the heap in bytes.
Returns
Zero if successful, non-zero otherwise.

◆ srealloc()

void * srealloc ( void *  p,
uint32_t  num_bytes 
)

Reallocate a block of memory with the specified new size.

Parameters
pThe pointer to the memory block to reallocate.
num_bytesThe new size in bytes.
Returns
A pointer to the reallocated memory block, or NULL if reallocation fails.

Variable Documentation

◆ boot_heap_tail

struct alloc_struct_t boot_heap_head boot_heap_tail
static