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

const correctness in public API #721

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

Xeverous
Copy link
Contributor

This patch adds const to pointers to data types which aren't modified.

There are few minor issues remaining - I did not changed these but please inform me what's your opinion on these:

  • nk_group_get_scroll - unlike with other getters, this getter can not use const context because the implementation modifies the context on one branch (the value is cached and created on-demand, which means getters need to be able to create it too)
  • nk_find_value - the use of const would be questionable here, especially given the fact that the function returns non-const pointer. Perhaps it needs a second overload with both const input and const output?
  • nk_combo_callback, nk_combobox_callback - shouldn't item_getter be changed from void(*)(void*, int, const char**) to const char*(*)(void*, int)?
  • struct nk_font* nk_font_atlas_add_from_memory(struct nk_font_atlas *atlas, void *memory, nk_size size, float height, const struct nk_font_config *config); and likewise nk_font_atlas_add_compressed takes a non-const pointer to the memory but looking at the implementation this memory is never modified (actually copied).

@RobLoach RobLoach merged commit f169ee6 into Immediate-Mode-UI:master Nov 7, 2024
1 check passed
@Xeverous Xeverous mentioned this pull request Dec 13, 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