Return NULL when aligning forward if ptr is NULL

This commit is contained in:
Abdelrahman Said 2024-02-24 20:26:37 +00:00
parent 9513c05b75
commit a169fe3654

View File

@ -2,10 +2,15 @@
#include "aliases.h"
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
void *mem_util_align_forward(void *ptr, u64 alignment) {
if (!ptr) {
return NULL;
}
assert(is_power_of_two(alignment));
uptr p = (uptr)ptr;