Skip to content

Commit

Permalink
mimalloc: add strdup and strndup overrride
Browse files Browse the repository at this point in the history
  • Loading branch information
krichprollsch committed Apr 19, 2024
1 parent a3e91de commit 304a28a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/mimalloc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ pub export fn c_alloc(nmemb: usize, size: usize) callconv(.C) ?*anyopaque {
return c.mi_heap_calloc(heap.?, nmemb, size);
}

pub export fn str_dup(s: [*c]const u8) callconv(.C) [*c]u8 {
if (heap == null) return null;
return c.mi_heap_strdup(heap.?, s);
}

pub export fn strn_dup(s: [*c]const u8, size: usize) callconv(.C) [*c]u8 {
if (heap == null) return null;
return c.mi_heap_strndup(heap.?, s, size);
}

// NOOP, use destroy to clear all the memory allocated at once.
pub export fn f_ree(_: ?*anyopaque) callconv(.C) void {
return;
Expand Down

0 comments on commit 304a28a

Please sign in to comment.