mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Added $converable / $castable. Simplify and corrected if try/catch parsing. Fix bug with { [A] = 1 }
This commit is contained in:
committed by
Christoffer Lerno
parent
7e0a29ef40
commit
812bd8b3d0
22
lib/std/core/mem_array.c3
Normal file
22
lib/std/core/mem_array.c3
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2021 Christoffer Lerno. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license
|
||||
// a copy of which can be found in the LICENSE_STDLIB file.
|
||||
module std::core::mem::array;
|
||||
|
||||
/**
|
||||
* @require usize.typeid.max / elements > $Type.sizeof
|
||||
**/
|
||||
macro alloc($Type, usize elements)
|
||||
{
|
||||
$Type* ptr = mem::alloc($Type.sizeof * elements, $alignof($Type));
|
||||
return ptr[:elements];
|
||||
}
|
||||
|
||||
/**
|
||||
* @require (usize.typeid.max / elements > $Type.sizeof)
|
||||
**/
|
||||
macro make($Type, usize elements)
|
||||
{
|
||||
$Type* ptr = mem::calloc($sizeof($Type) * elements, $alignof($Type));
|
||||
return ptr[:elements];
|
||||
}
|
||||
Reference in New Issue
Block a user