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

Add const qualifiers to nk_allocator in more places. #642

Merged
merged 2 commits into from
May 25, 2024

Conversation

SnootierMoon
Copy link
Contributor

The nk_allocator struct consists of 3 fields, userdata (application-specified ptr), alloc (allocate function), and free (deallocate function). None of these are modified once provided by the library user as far as I can tell, so it should be safe to make this struct const in all API parameters.

Since stb-truetype uses a void* for allocation data, a cast is necessary. But, since the nk_stbtt_malloc/nk_stbtt_free implementations don't modify the nk_allocator (as the potentially mutable allocator is stored indirectly in nk_allocator.userdata), this should be fine as well.

Copy link
Contributor

@RobLoach RobLoach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@RobLoach RobLoach merged commit 47f570c into Immediate-Mode-UI:master May 25, 2024
1 check passed
@RobLoach RobLoach mentioned this pull request Jun 14, 2024
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

Successfully merging this pull request may close these issues.

2 participants