Updated memory allocator. Fix in printf printing pointers. Added aligned_alloc to libc module. Renamed MemoryArena -> ArenaAllocator. New temp allocator. @pool(), @scoped, @tscoped macros. Bump to 0.3.2.

This commit is contained in:
Christoffer Lerno
2022-08-01 15:25:26 +02:00
parent 272f134e78
commit 550bca79e9
15 changed files with 337 additions and 153 deletions

View File

@@ -12,11 +12,29 @@ macro alloc($Type, usize elements)
return ptr[:elements];
}
/**
* @require usize.max / elements > $Type.sizeof
**/
macro talloc($Type, usize elements)
{
$Type* ptr = mem::talloc($Type.sizeof * elements, $alignof($Type[1]));
return ptr[:elements];
}
/**
* @require (usize.max / elements > $Type.sizeof)
**/
macro make($Type, usize elements)
{
$Type* ptr = mem::calloc($sizeof($Type) * elements, $alignof($Type));
$Type* ptr = mem::calloc($sizeof($Type) * elements, $alignof($Type[1]));
return ptr[:elements];
}
/**
* @require (usize.max / elements > $Type.sizeof)
**/
macro tmake($Type, usize elements)
{
$Type* ptr = mem::tcalloc($sizeof($Type) * elements, $alignof($Type[1]));
return ptr[:elements];
}