Cleanup: Mark large arrays of of constant data as const.

For background information see D5345

Reviewers: brecht, sergey

Differential Revision: https://developer.blender.org/D5345
This commit is contained in:
2019-08-04 14:24:29 -06:00
parent 37cef86f0d
commit 418fdee5dc
2 changed files with 9 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ typedef struct SobolDirectionNumbers {
/* Keep simple alignment. */
/* clang-format off */
static SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS - 1] = {
static const SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS - 1] = {
{2, 1, 0, {1}},
{3, 2, 1, {1, 3}},
{4, 3, 1, {1, 3, 1}},
@@ -21279,10 +21279,10 @@ void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions
v[i] = 1 << (31 - i); // all m's = 1
for (int dim = 1; dim < dimensions; dim++) {
SobolDirectionNumbers *numbers = &SOBOL_NUMBERS[dim - 1];
uint s = numbers->s;
uint a = numbers->a;
uint *m = numbers->m;
const SobolDirectionNumbers *numbers = &SOBOL_NUMBERS[dim - 1];
const uint s = numbers->s;
const uint a = numbers->a;
const uint *m = numbers->m;
v = vectors[dim];

View File

@@ -94,11 +94,11 @@ int main(int argc, char **argv)
fprintf(fpout, "/* DataToC output of file <%s> */\n\n", argv[1]);
/* Quiet 'missing-variable-declarations' warning. */
fprintf(fpout, "extern int datatoc_%s_size;\n", argv[1]);
fprintf(fpout, "extern char datatoc_%s[];\n\n", argv[1]);
fprintf(fpout, "extern const int datatoc_%s_size;\n", argv[1]);
fprintf(fpout, "extern const char datatoc_%s[];\n\n", argv[1]);
fprintf(fpout, "int datatoc_%s_size = %d;\n", argv[1], (int)size);
fprintf(fpout, "char datatoc_%s[] = {\n", argv[1]);
fprintf(fpout, "const int datatoc_%s_size = %d;\n", argv[1], (int)size);
fprintf(fpout, "const char datatoc_%s[] = {\n", argv[1]);
while (size--) {
/* if we want to open in an editor
* this is nicer to avoid very long lines */