mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix foreach body copy. Moved deref / addr into special functions. Cleaned up access. Remove .sizeof .alignof .qnameof .nameof, create $qnameof $nameof
This commit is contained in:
committed by
Christoffer Lerno
parent
2815a6d02e
commit
9f42ddb68d
@@ -40,7 +40,7 @@ private func void LinkedList.linkFirst(LinkedList *list, Type value)
|
||||
private func void LinkedList.linkLast(LinkedList *list, Type value)
|
||||
{
|
||||
Node *last = list.last;
|
||||
Node *new_node = mem::alloc(Node.sizeof);
|
||||
Node *new_node = mem::alloc($sizeof(Node));
|
||||
*new_node = { .prev = last, .value = value };
|
||||
list.last = new_node;
|
||||
if (!last)
|
||||
|
||||
@@ -13,7 +13,7 @@ private func void List.ensureCapacity(List *list) @inline
|
||||
if (list.capacity == list.size)
|
||||
{
|
||||
list.capacity = list.capacity ? 2 * list.capacity : 16;
|
||||
list.entries = mem::realloc(list.entries, Type.sizeof * list.capacity);
|
||||
list.entries = mem::realloc(list.entries, $sizeof(Type) * list.capacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ Allocator main_allocator = { &system_malloc_function, null };
|
||||
|
||||
macro malloc($Type)
|
||||
{
|
||||
return ($Type*)(mem::alloc($Type.sizeof));
|
||||
return ($Type*)(mem::alloc($sizeof($Type)));
|
||||
}
|
||||
|
||||
func void* alloc(usize size, usize elements = 1) @inline
|
||||
|
||||
Reference in New Issue
Block a user