From 314aea5ffca5a274c55339a6c426bc87c40f2886 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 12 Aug 2024 15:31:23 +0200 Subject: [PATCH] Fixed memory allocation on MacOS --- lib/mem/alloc_linux.q | 5 +++++ lib/mem/alloc_mac.q | 5 +++++ lib/mem/{alloc.q => free.q} | 4 ---- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 lib/mem/alloc_linux.q create mode 100644 lib/mem/alloc_mac.q rename lib/mem/{alloc.q => free.q} (51%) diff --git a/lib/mem/alloc_linux.q b/lib/mem/alloc_linux.q new file mode 100644 index 0000000..70929fe --- /dev/null +++ b/lib/mem/alloc_linux.q @@ -0,0 +1,5 @@ +import sys + +alloc(length Int) -> Pointer { + return sys.mmap(0, length, 0x1|0x2, 0x02|0x20) +} \ No newline at end of file diff --git a/lib/mem/alloc_mac.q b/lib/mem/alloc_mac.q new file mode 100644 index 0000000..bdeb356 --- /dev/null +++ b/lib/mem/alloc_mac.q @@ -0,0 +1,5 @@ +import sys + +alloc(length Int) -> Pointer { + return sys.mmap(0, length, 0x1|0x2, 0x02|0x1000) +} \ No newline at end of file diff --git a/lib/mem/alloc.q b/lib/mem/free.q similarity index 51% rename from lib/mem/alloc.q rename to lib/mem/free.q index 747290a..432d65d 100644 --- a/lib/mem/alloc.q +++ b/lib/mem/free.q @@ -1,9 +1,5 @@ import sys -alloc(length Int) -> Pointer { - return sys.mmap(0, length, 0x1|0x2, 0x02|0x20|0x100) -} - free(address Pointer, length Int) -> Int { return sys.munmap(address, length) } \ No newline at end of file