Added memory size defines

This commit is contained in:
Randy Jordan 2025-07-05 11:40:16 -05:00
parent ffe2af37fe
commit 855cbd04a9
Signed by: Randy-Jordan
GPG Key ID: 153FF450FDC74D1A
2 changed files with 5 additions and 1 deletions

View File

@ -7,6 +7,10 @@
#define SIZEOF(x) (ptrdiff_t)sizeof(x)
#define NELEMS(a) (sizeof(a) / sizeof(*(a)))
#define LEN(s) (NELEMS(s) - 1)
#define KB(x) ((size_t)(x) << 10) // 1 KB = 1024 bytes
#define MB(x) ((size_t)(x) << 20) // 1 MB = 1024 * 1024 bytes
#define GB(x) ((size_t)(x) << 30) // 1 GB = 1024 * 1024 * 1024 bytes
extern const Exception out_of_memory; // OOM Exception
extern void *mem_alloc (size_t nbytes,const char *file, int line);

View File

@ -20,7 +20,7 @@ static bool isZeroed(void *memory, unsigned int size)
int main(void){
char *buf = ALLOC(BUFSZ);
char *buf = ALLOC(MB(20));
ASSERTED(buf != NULL);
ASSERTED(isZeroed(buf, BUFSZ) == false);
FREE(buf);