File tree 2 files changed +5
-4
lines changed 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 {
206
206
207
207
/// Zig replacement for realloc
208
208
export 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
- }
213
209
// TODO: Call realloc instead
214
210
// const mem = memory_allocator.allocator().realloc(old_mem[0..???], size) catch {
215
211
// @panic("*** realloc error: out of memory");
216
212
// };
217
213
const mem = memory_allocator .allocator ().alloc (u8 , size ) catch {
218
214
@panic ("*** realloc error: out of memory" );
219
215
};
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
+ }
220
221
return mem .ptr ;
221
222
}
222
223
You can’t perform that action at this time.
0 commit comments