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
@@ -36,7 +36,7 @@ fn Stream ByteWriter.as_stream(ByteWriter* writer)
|
||||
fn void ByteWriter.destroy(ByteWriter* writer)
|
||||
{
|
||||
if (!writer.allocator) return;
|
||||
if (void* ptr = writer.bytes.ptr) writer.allocator.free(ptr)!!;
|
||||
if (void* ptr = writer.bytes.ptr) free(ptr, .using = writer.allocator);
|
||||
*writer = { };
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ fn void! ByteWriter.ensure_capacity(ByteWriter* writer, usz len) @inline
|
||||
if (writer.bytes.len > len) return;
|
||||
if (len < 16) len = 16;
|
||||
usz new_capacity = math::next_power_of_2(len);
|
||||
char* new_ptr = writer.allocator.realloc(writer.bytes.ptr, new_capacity)?;
|
||||
char* new_ptr = realloc_checked(writer.bytes.ptr, new_capacity, .using = writer.allocator)?;
|
||||
writer.bytes = new_ptr[:new_capacity];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user