From 304a28a79d4cf1997d40800472029462ba08a222 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 18 Apr 2024 15:39:13 +0200 Subject: [PATCH] mimalloc: add strdup and strndup overrride --- src/mimalloc.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mimalloc.zig b/src/mimalloc.zig index b9d563e4..58f98780 100644 --- a/src/mimalloc.zig +++ b/src/mimalloc.zig @@ -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;