Return NULL when aligning forward if ptr is NULL
This commit is contained in:
parent
9513c05b75
commit
a169fe3654
@ -2,10 +2,15 @@
|
|||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||||
|
|
||||||
void *mem_util_align_forward(void *ptr, u64 alignment) {
|
void *mem_util_align_forward(void *ptr, u64 alignment) {
|
||||||
|
if (!ptr) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
assert(is_power_of_two(alignment));
|
assert(is_power_of_two(alignment));
|
||||||
|
|
||||||
uptr p = (uptr)ptr;
|
uptr p = (uptr)ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user