Updated malloc/calloc/realloc/free deprecation of old helper functions. Add checks to prevent incorrect alignment on types when using malloc. Better errors from $assert. Added @deprecated. Fixed issue using named arguments after varargs.

This commit is contained in:
Christoffer Lerno
2023-02-27 14:51:35 +01:00
committed by Christoffer Lerno
parent 8ad8af861e
commit dd4edfb747
28 changed files with 705 additions and 343 deletions

View File

@@ -44,7 +44,7 @@ fn bool contains(String haystack, String needle)
macro @dupe(value)
{
$typeof(&value) temp = malloc_checked($sizeof(value))?;
$typeof(&value) temp = malloc_checked($typeof(value))?;
*temp = value;
return temp;
}

View File

@@ -65,13 +65,13 @@ fn void main()
};
mem::@tscoped()
{
io::printf("Malloc: %p\n", malloc(23));
io::printf("Malloc: %p\n", malloc(23));
io::printf("Malloc: %p\n", (void*)malloc(23));
io::printf("Malloc: %p\n", (void*)malloc(23));
};
io::printf("Malloc: %p\n", malloc(23));
io::printf("Malloc: %p\n", (void*)malloc(23));
@pool()
{
io::printf("Talloc: %p\n", tmalloc(22));
io::printf("Talloc: %p\n", (void*)tmalloc(22));
};
testAllocator(mem::temp_allocator(), 126);
testAllocator(mem::temp_allocator(), 12600);