|
Embedded Artistry Framework
Embedded Systems C++ Framework
|
#include <assert.h>#include <stdbool.h>#include <stdint.h>#include <stdlib.h>#include "aligned_malloc.h"#include "malloc.h"
Macros | |
| #define | align_up(num, align) (((num) + ((align)-1)) & ~((align)-1)) |
| Simple macro for making sure memory addresses are aligned to the nearest power of two. More... | |
| #define | PTR_OFFSET_SZ sizeof(offset_t) |
| Macro for accessing the size of our current pointer offset. More... | |
Typedefs | |
| typedef uint16_t | offset_t |
| Number of bytes we're using for storing the aligned pointer offset. More... | |
Functions | |
| void * | aligned_malloc (size_t align, size_t size) |
| We will call malloc with extra bytes for our header and the offset required to guarantee the desired alignment. More... | |
| void | aligned_free (void *ptr) |
| aligned_free works like free(), but we work backwards from the returned pointer to find the correct offset and pointer location to return to free() Note that it is VERY BAD to call free() on an aligned_malloc() pointer. More... | |
| #define align_up | ( | num, | |
| align | |||
| ) | (((num) + ((align)-1)) & ~((align)-1)) |
Simple macro for making sure memory addresses are aligned to the nearest power of two.
| #define PTR_OFFSET_SZ sizeof(offset_t) |
Macro for accessing the size of our current pointer offset.
| void aligned_free | ( | void * | ptr | ) |
aligned_free works like free(), but we work backwards from the returned pointer to find the correct offset and pointer location to return to free() Note that it is VERY BAD to call free() on an aligned_malloc() pointer.
Free aligned memory.
References assert, free(), and p.
Referenced by aligned_malloc_test(), embutil::aligned_sptr(), embutil::aligned_uptr(), and posix_memalign_test().

We will call malloc with extra bytes for our header and the offset required to guarantee the desired alignment.
Allocated aligned memory.
References align_up, assert, malloc(), NULL, p, and PTR_OFFSET_SZ.
Referenced by aligned_malloc_test(), embutil::aligned_sptr(), embutil::aligned_uptr(), and posix_memalign().

1.8.15