NanoVG is an old C library. Unfortunately, in C libraries, the use of const is often absent. This is either because some libraries predate the introduction of the const keyword or, most of the time, due to oversights. NanoVG is no exception and, for example, does not use const for a buffer in the nvgCreateImageMem function
NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata);
However, this buffer is used by the
STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
function, which indeed expects a "const.".
The purpose of this pull request is to make Borealis const-correct.
Instead of using const_cast<unsigned char*>(buf) in the source code of a project using Borealis, it is preferable to use only buf and apply const_cast<unsigned char*>(buf) directly within the Borealis library.
NanoVG is an old C library. Unfortunately, in C libraries, the use of
const
is often absent. This is either because some libraries predate the introduction of theconst
keyword or, most of the time, due to oversights. NanoVG is no exception and, for example, does not useconst
for a buffer in thenvgCreateImageMem
functionHowever, this buffer is used by the
function, which indeed expects a "const.".
The purpose of this pull request is to make Borealis const-correct. Instead of using
const_cast<unsigned char*>(buf)
in the source code of a project using Borealis, it is preferable to use onlybuf
and applyconst_cast<unsigned char*>(buf)
directly within the Borealis library.