Added memory size defines
This commit is contained in:
parent
ffe2af37fe
commit
855cbd04a9
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user