mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Single code path for kind/inner/len/sizeof on type and typeid. Fix of #493. Bump to 0.2.24. Remove ´func´ deprecated keyword. Unify builtin access. Enum and fault name reflection.
23 lines
604 B
C
23 lines
604 B
C
// 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.max / elements > $Type.sizeof
|
|
**/
|
|
macro alloc($Type, usize elements)
|
|
{
|
|
$Type* ptr = mem::alloc($Type.sizeof * elements, $alignof($Type));
|
|
return ptr[:elements];
|
|
}
|
|
|
|
/**
|
|
* @require (usize.max / elements > $Type.sizeof)
|
|
**/
|
|
macro make($Type, usize elements)
|
|
{
|
|
$Type* ptr = mem::calloc($sizeof($Type) * elements, $alignof($Type));
|
|
return ptr[:elements];
|
|
}
|