Any memory allocated inside a memscoped becomes invalid when the lambda returns. Make sure to do any work that requires the pointer inside the lambda, or use an arena to allocate if the pointer needs to stay valid.
Landry Norris
08/07/2023, 4:38 PM
As a general rule, never let a pointer leave a memScoped block.
l
leandro
08/07/2023, 4:42 PM
Yeah I should have pasted the real code, but AFAIK I should be safe 🙏
it really is something akin to:
That snippet looks to be handling memory right. Is
uniChars.size
<= 2? Have you verified that uniChars is correct?
Landry Norris
08/07/2023, 4:50 PM
I would assume "doesn't work" in this case means it always returns false? Have you validated that the uniChars input is valid, since that should be what affects functionality here. You don't seem to need the glyphs array, so I wonder what happens if you provide null? The docs don't clarify this.
l
leandro
08/08/2023, 12:42 PM
That's right, or almost, it always returns true. On StackOverflow this is used to figure whether an emoji can be rendered, but on my case I know that some must return false (testing on an older iOS version).
I still couldn't figure it out, but I found out that
glyphs
gets populated if it really can be rendered by the OS. That is, I get what I want if I don't check for the return type of