summaryrefslogtreecommitdiff
path: root/src/util/asset_manager.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-03 08:03:57 +0100
committerskal <pascal.massimino@gmail.com>2026-02-03 08:03:57 +0100
commit6d4aeb4120230899589326b5fd87afca58654c05 (patch)
tree2b14534b9ab7bf0d1be203a0a8195dcc49a5bbfe /src/util/asset_manager.h
parentf7609d0bdc3df851195c378eabc2715cb4c30bbe (diff)
feat(assets): Enforce 16-byte alignment and string safety
Updates asset_packer to align static asset arrays to 16 bytes and append a null-terminator. This allows assets to be safely reinterpreted as typed pointers (e.g., float*, const char*) without copying. Updates AssetManager documentation to reflect these guarantees.
Diffstat (limited to 'src/util/asset_manager.h')
-rw-r--r--src/util/asset_manager.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/util/asset_manager.h b/src/util/asset_manager.h
index b9cd778..062cd0f 100644
--- a/src/util/asset_manager.h
+++ b/src/util/asset_manager.h
@@ -25,5 +25,9 @@ struct AssetRecord {
};
// Generic interface
+// Retrieves a pointer to the asset data.
+// - Static assets are guaranteed to be 16-byte aligned.
+// - Static assets are guaranteed to be null-terminated (safe as C-strings).
+// - 'out_size' returns the original asset size (excluding the null terminator).
const uint8_t* GetAsset(AssetId asset_id, size_t* out_size = nullptr);
void DropAsset(AssetId asset_id, const uint8_t* asset);