mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
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:
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user