SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk_memory_allocator_malloc.h
Go to the documentation of this file.
1/*
2 * SuperTinyKernel(TM) RTOS: Lightweight High-Performance Deterministic C++ RTOS for Embedded Systems.
3 *
4 * Source: https://github.com/SuperTinyKernel-RTOS
5 *
6 * Copyright (c) 2022-2026 Neutron Code Limited <stk@neutroncode.com>. All Rights Reserved.
7 * License: MIT License, see LICENSE for a full text.
8 */
9
10#ifndef STK_MEMORY_ALLOCATOR_MALLOC_H_
11#define STK_MEMORY_ALLOCATOR_MALLOC_H_
12
14
44
45// Private memory allocators (we define malloc, free here to overcome absence of declaration in
46// case of -ffreestanding compiler flag).
47extern "C" void *malloc(size_t size);
48extern "C" void free(void *ptr);
49
51{
52 return malloc(size);
53}
54
56{
57 free(ptr);
58}
59
60stk::memory::MemoryAllocator::Stats stk::memory::MemoryAllocator::Weak::GetStats()
61{
62 // no statistics from malloc
63 return Stats();
64}
65
66#endif /* STK_MEMORY_ALLOCATOR_MALLOC_H_ */
Memory allocator front-end with checked API and its weak backend hooks: stk::memory::MemoryAllocator.
void * malloc(size_t size)
void free(void *ptr)
Snapshot of the memory allocator's statistics.
static Stats GetStats() __stk_weak
Get stats of memory allocation (backend hook, optional).
static void Free(void *ptr) __stk_weak
Free the memory chunk (backend hook).
static void * Allocate(size_t size) __stk_weak
Allocate the memory chunk (backend hook).