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
reduce internal dependency on 0 terminated strings #5220
Conversation
3b832a6
to
e29e1e5
Compare
This is |
The 0 termination can be more than one byte long. And I want to get rid of the 0 termination anyway. |
Yes, but this pattern:
is repeated quite a few times. And I assume there are more to come. Another option would be to add a new member function to |
I don't like strndup - I have a hard time remembering just what it does, and it likely has not received the intensive optimizations that memcpy has. I see no advantage to it. Another thing I want to do to StringExp is have it always store its data as UTF8, and then convert to wchar or dchar only on demand. I have noticed latent bugs in dmd where it is assumed to be UTF8. Always storing it as UTF8 will eliminate those bugs and will make the logic much simpler to work with. |
But please pull this one first :-) |
So what I see here is this pattern repeated three times:
This screams for being put in a function. Either call |
Which reminds me, we can remove those x prefixes now it's in D. Possible PR incoming...
I would concur here. |
done |
final char* toStringz() | ||
{ | ||
auto nbytes = len * sz; | ||
char* s = cast(char*)mem.xmalloc(nbytes + sz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto
...
reduce internal dependency on 0 terminated strings
Thanks, this is much better. |
Don't they still need to be called from the glue layer? |
If I need to allocate memory, there's gcc gc. The problem was that when you (or someone) changed around the Array implementation to Array, suddenly rmem.h was being pulled into places it wasn't welcome. I reckon that the uses of rmem exposed aren't necessary if allocation is kept in the frontend. |
|
This pull request introduced a regression: |
The idea is to eventually find and fix them all, then switch to D style strings. But finding them all is hard.