[Snek] How to return a string from builtin?
dottedmag at dottedmag.net
Wed Feb 19 10:05:49 PST 2020
How do I return a string from a builtin?
I've got it working in the following way, but it seems suboptimal:
size_t len = strlen(s);
char *new = snek_alloc(len + 1);
memcpy(new, s, len);
— `s` here is always one of 8 constants, so I can allocate 8 strings
at the start and return one of them, but maybe there is a way to
completely avoid allocations?
More information about the Snek