Created
September 2, 2019 10:43
-
-
Save giraphics/6d7659094273b0276cdf71a1c319b985 to your computer and use it in GitHub Desktop.
MEMORY MANAGEMENT HELPER
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TO_POINTER(value) ((void*)(value)) | |
#define FORWARD_POINTER(pointer, offset) ((void*)((uintptr_t)TO_POINTER(pointer) + offset)) | |
#define POINTER_TO_UINT(pointer) ((uintptr_t)(pointer)) | |
#define ALIGN_POINTER(pointer, base) TO_POINTER(((POINTER_TO_UINT(pointer))+((base)-1L)) & ~((base)-1L)) | |
or | |
#define ALIGN_POINTER(pointer, base) TO_POINTER((UT_POINTER_TO_UINT(pointer)) + ((UT_POINTER_TO_UINT(pointer)) % base)) | |
#define IS_POINTER_ALIGNED(pointer, alignment) (((uintptr_t)pointer & (uintptr_t)(alignment - 1L)) == 0) | |
or | |
#define IS_POINTER_ALIGNED(pointer, alignment) (((uintptr_t)pointer % (uintptr_t)alignment) == 0) | |
#define IN_RANGE(value, min_value, max_value) (value >= min_value && value <= max_value) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment