Hello,
Is it possible to hook my own alloc / dealloc functions to work with --gc:arc? I couldn't find examples on this.
Thanks!
Thanks!
However, it's not working for me. I'm doing:
patchFile("system", "memalloc", "patches/memalloc")
Does it look good? my memalloc.nim file contains the same procs that are defined in the system/memalloc one, but hooked into my allocator. However, it seems like nothing is changed
Following up:
In config.nims I have tried all these different options without any success.
patchFile("system", "", "custom_alloc")
patchFile("system", "mm/malloc", "custom_alloc")
patchFile("system", "memalloc", "custom_alloc")
Whenever I use something like allocImpl in my code, I have the ambiguous call error:
Error: ambiguous call;
both system.allocImpl(size: Natural) [declared in /home/francesco/.choosenim/toolchains/nim-1.4.4/lib/system/mm/malloc.nim(4, 6)]
and custom_alloc.allocImpl(size: Natural) [declared in /home/francesco/Sources/omnijit/omnijit/custom_alloc.nim(3, 6)]
match for: (int literal(10))
The new allocImpl won't even work internally for any other calls (e.g. when allocating a seq or string)
After many tries, I managed to find a solution. The file to patch is:
patchFile("stdlib", malloc", "custom_alloc")