memory_arena
Loading...
Searching...
No Matches
Functions
arena_math.h File Reference

Math utility functions for memory alignment and overflow-safe arithmetic. More...

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

Go to the source code of this file.

Functions

static size_t align_up (size_t value, size_t alignment)
 Align a value upwards to the nearest multiple of alignment.
 
static size_t next_power_of_two (size_t x)
 Return the next power of two greater than or equal to x.
 
static bool would_overflow_mul (size_t a, size_t b, size_t *result)
 Perform a checked multiplication of two size_t values.
 

Detailed Description

Math utility functions for memory alignment and overflow-safe arithmetic.

Author
Toonsa
Date
2025

This header defines a small collection of inline utility functions used internally in the arena allocator for:

These helpers are optimized for performance and portability across platforms.

Note
This file contains only inline functions and does not require linking.

Definition in file arena_math.h.