mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
committed by
Christoffer Lerno
parent
8ad8af861e
commit
dd4edfb747
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user