Skip to content
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

consider using size_t instead of int for length #14

Open
iljavs opened this issue Jun 2, 2021 · 1 comment
Open

consider using size_t instead of int for length #14

iljavs opened this issue Jun 2, 2021 · 1 comment

Comments

@iljavs
Copy link

iljavs commented Jun 2, 2021

Currently str uses (signed) int for all lengths/sizes/capacity. when handling large strings (~2g and up, which is fairly realistic these days on 64 bit machines) signedness issues occur and memory corruption happens in various places.

@ocornut
Copy link
Owner

ocornut commented Jul 6, 2021

The type was designed to be compact.
We currently don't even use 32-bits for size but 21-bits which is even lower, so your statement seems to be coming from a strictly theoretical position rather than actual need, since you didn't realize it was already capped to 21-bits.

The current packing made sense on 32-bits targets but effectively we have 4 bytes of unused padding on 64-bits targets. There is a todo to actually update to 32-bit storage for size, but I suppose we could use 53 bits just as well..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants