delete: Deleted helper utility funcitons
This commit is contained in:
@@ -64,10 +64,4 @@ SizeResult arena_get_align_padding(Arena *arena, size_t alignment);
|
|||||||
// I shouldn't cover.
|
// I shouldn't cover.
|
||||||
ArenaErr arena_ensure_capacity(Arena *arena, size_t size, size_t alignment);
|
ArenaErr arena_ensure_capacity(Arena *arena, size_t size, size_t alignment);
|
||||||
|
|
||||||
// Should be moved to something like general utilities,
|
|
||||||
// i should make one for all my c projects
|
|
||||||
static inline bool mul_size_t_safe(size_t a, size_t b, size_t *out);
|
|
||||||
static inline bool add_size_t_safe(size_t a, size_t b, size_t *out);
|
|
||||||
static inline bool is_power_of_two(size_t x);
|
|
||||||
|
|
||||||
#endif // !ARENA_H
|
#endif // !ARENA_H
|
||||||
|
|||||||
22
src/arena.c
22
src/arena.c
@@ -200,26 +200,4 @@ void *arena_unwrap_pointer(ArenaPointer p) {
|
|||||||
return p.arena->buffer + p.offset;
|
return p.arena->buffer + p.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool is_power_of_two(size_t x) {
|
|
||||||
return x != 0 && (x & (x - 1)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool add_size_t_safe(size_t a, size_t b, size_t *out) {
|
|
||||||
if (a > SIZE_MAX - b) return true;
|
|
||||||
*out = a + b;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool mul_size_t_safe(size_t a, size_t b, size_t *out) {
|
|
||||||
if (out == NULL) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a != 0 && b > SIZE_MAX / a) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
*out = a * b;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user