File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -206,17 +206,18 @@ export fn malloc(size: usize) ?*anyopaque {
206206
207207/// Zig replacement for realloc
208208export fn realloc (old_mem : [* c ]u8 , size : usize ) ? * anyopaque {
209- if (old_mem != null ) {
210- // TODO: How to free without the slice length?
211- // memory_allocator.allocator().free(old_mem[0..???]);
212- }
213209 // TODO: Call realloc instead
214210 // const mem = memory_allocator.allocator().realloc(old_mem[0..???], size) catch {
215211 // @panic("*** realloc error: out of memory");
216212 // };
217213 const mem = memory_allocator .allocator ().alloc (u8 , size ) catch {
218214 @panic ("*** realloc error: out of memory" );
219215 };
216+ _ = memcpy (mem .ptr , old_mem , size );
217+ if (old_mem != null ) {
218+ // TODO: How to free without the slice length?
219+ // memory_allocator.allocator().free(old_mem[0..???]);
220+ }
220221 return mem .ptr ;
221222}
222223
You can’t perform that action at this time.
0 commit comments