Skip to content

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
@Xeverous Xeverous deleted the const-correctness branch September 28, 2025 08:21
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