From 3e3280286242fd3459476d5c8f74faee7c58c27a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 10 Jun 2023 10:30:56 -0400 Subject: [PATCH] Add A1.allocate() template to allocate struct/class instances --- src/hulk/hurl/a1.d | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hulk/hurl/a1.d b/src/hulk/hurl/a1.d index df1d786..9a9c483 100644 --- a/src/hulk/hurl/a1.d +++ b/src/hulk/hurl/a1.d @@ -50,4 +50,15 @@ struct A1 return cast(void *)address; } + + /** + * Allocate memory to store an instance of a given type. + * + * @return Address of allocated memory. This address will always be aligned + * to a multiple of 16 bytes. + */ + public static T * allocate(T)() + { + return cast(T *)allocate(T.sizeof); + } }