-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drop use of slice header #117
Conversation
update from origin
The memory allocation makes me somewhat nervous. Could we do something a little silly and allocate a |
Such a change would break the current contract. With the current "hard" allocation, the memory where the strings are kept in is stable. A Go-allocated memory area could be moved any time, invalidating any pointer. |
Addendum: Or did you mean something like first to allocate a continuous byte array for all the strings in Go land, from which then a single |
I was thinking something along the lines of
|
Ah, now I understand you - it's not the memory allocation that bothers you, but the way the pointer is cast to Go land. |
I might frame it as the size of the memory allocation is what caused me to think of alternatives; I worry that a big allocation like that might be tricky on a memory-constrained system. |
I'm not sure if we're talking about the same thing. Neither my nor your suggested change would modify the If you are referring to this line: What were you referring to? (I'm happy to add your change as well, I want to be sure we're on the same page) |
Oh oh I understand now, I misread it. Thanks for the detailed explanation! LGTM. |
This PR changes how a raw array of bytes is cast back into a slice.
It is in preparation to handle go-gl/gl#132 .
The conversion is now done using a pointer to an arbitrarily large memory block, of which a slice is taken. The size is large enough to cover everything practical, and small enough to still be available on 32bit systems.
I also added another check, to avoid handling an empty slice because of empty strings - which would cause another error.