From 61b3af5b087a7afe935e4318347757bab8eddf07 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 24 Aug 2024 14:51:05 +0100 Subject: [PATCH] `MemFree` as a procedure group for both `rawptr` and `cstring` --- vendor/raylib/raylib.odin | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/vendor/raylib/raylib.odin b/vendor/raylib/raylib.odin index b2010c7a1..45816ab1a 100644 --- a/vendor/raylib/raylib.odin +++ b/vendor/raylib/raylib.odin @@ -1029,7 +1029,6 @@ foreign lib { SetTraceLogLevel :: proc(logLevel: TraceLogLevel) --- // Set the current threshold (minimum) log level MemAlloc :: proc(size: c.uint) -> rawptr --- // Internal memory allocator MemRealloc :: proc(ptr: rawptr, size: c.uint) -> rawptr --- // Internal memory reallocator - MemFree :: proc(ptr: rawptr) --- // Internal memory free // Set custom callbacks // WARNING: Callbacks setup is intended for advance users @@ -1688,6 +1687,24 @@ TextFormatAlloc :: proc(text: cstring, args: ..any) -> cstring { } +// Internal memory free +MemFree :: proc{ + MemFreePtr, + MemFreeCstring, +} + + +@(default_calling_convention="c") +foreign lib { + @(link_name="MemFree") + MemFreePtr :: proc(ptr: rawptr) --- +} + +MemFreeCstring :: proc "c" (s: cstring) { + MemFreePtr(rawptr(s)) +} + + MemAllocator :: proc "contextless" () -> mem.Allocator { return mem.Allocator{MemAllocatorProc, nil} }