From 6d4aeb4120230899589326b5fd87afca58654c05 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 3 Feb 2026 08:03:57 +0100 Subject: 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. --- src/util/asset_manager.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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); -- cgit v1.2.3