Return NULL when aligning forward if ptr is NULL
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user