diff options
author | quou <quou@disroot.org> | 2024-09-30 21:31:21 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-09-30 21:31:21 +1000 |
commit | 3aa1183d3f9032d1d17c295e3f3a1dbeab57ab66 (patch) | |
tree | fd06404cbd4ee8ed10a04d5bace424b79e71b824 | |
parent | 800559b72d31126ea6ae787f2b470f7824eafaa3 (diff) |
assert that assets are always aligned properly.
-rw-r--r-- | asset.c | 6 | ||||
-rw-r--r-- | memory.c | 2 | ||||
-rw-r--r-- | memory.h | 2 |
3 files changed, 7 insertions, 3 deletions
@@ -1,8 +1,12 @@ +#include "memory.h" #include "pack.h" +#include "plat.h" #include "asset.h" const unsigned char* get_asset(Asset_ID id) { - return &asset_data[asset_offset_table[id]]; + const void* ptr = &asset_data[asset_offset_table[id]]; + assert(aligned(ptr, allocation_default_alignment)); + return ptr; } const struct Bitmap* get_bitmap(Asset_ID id) { @@ -3,7 +3,7 @@ #include <stdint.h> #include <stddef.h> -int aligned(void* p, int a) { +int aligned(const void* p, int a) { return (uintptr_t)p % a == 0; } @@ -1,7 +1,7 @@ #ifndef memory_h #define memory_h -int aligned(void* p, int a); +int aligned(const void* p, int a); int align_size(int s, int a); typedef struct Arena { |