carragom
How to go from a JS string[] to a C array of pointers
I also have a couple of questions:
1. Will the return allocate new memory or reuse the underlying buffer?
2. Is there any advantage in using Uint8Array as return instead of just the BigUint64Array ?
21 replies
How to go from a JS string[] to a C array of pointers
Well that worked it's it's even simpler and more readable now. I would appreciate your keen eye on it. Specially the part about the WeakMap, I have no idea if that would be enough to prevent garbage collection.
21 replies
How to go from a JS string[] to a C array of pointers
Great insight. Extra allocations are definitively something to watch out for. I love the idea of creating pointers to the encoded chunks, seems to have the best of all worlds. Balancing unsafe memory with a WeakMap on the other hand feels like a very delicate procedure, but hey at this point everything feels a bit brittle. I will give a try and report back.
21 replies
How to go from a JS string[] to a C array of pointers
In order to understand your code I wrote a function based on it. It should achieve the same and should handle multi-byte characters. But do mind the possible bugs. If you find anything weird with it let me know. Here it's
21 replies
How to go from a JS string[] to a C array of pointers
Thanks a lot !!! This was driving me crazy. I think it's safe to say that this a complex task to get right and there should be a helper function in the std library to deal with this conversion. This looks like a like a very common data structure to find as function parameter
21 replies