Skip to content

Commit

Permalink
Don't use variable-length arrays
Browse files Browse the repository at this point in the history
since MSVC doesn't support VLAs
  • Loading branch information
rayrobdod committed Apr 14, 2024
1 parent ae1c47b commit 42ea3b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/c/jasc-pal-thumbnailer.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ void write_output(const struct Palette *const palette, const char *const filenam
}
size_t swatchesX = (size_t) floor(sqrt((double) palette->count));
size_t swatchesY = palette->count / swatchesX + (0 == palette->count % swatchesX ? 0 : 1);
size_t swatchWidths[swatchesX];
size_t *swatchWidths = calloc(swatchesX, sizeof(size_t));
for (size_t i = 0; i < swatchesX; i++) {
swatchWidths[i] = (((i + 1) * dimension) / swatchesX) - ((i * dimension) / swatchesX);
}
size_t swatchHeights[swatchesY];
size_t *swatchHeights = calloc(swatchesY, sizeof(size_t));
for (size_t i = 0; i < swatchesY; i++) {
swatchHeights[i] = (((i + 1) * dimension) / swatchesY) - ((i * dimension) / swatchesY);
}
Expand Down Expand Up @@ -258,6 +258,8 @@ void write_output(const struct Palette *const palette, const char *const filenam
fwrite_png_chunk((uint8_t*) "IEND", 0, (uint8_t*) "", f);

fclose(f);
free(swatchWidths);
free(swatchHeights);
}


Expand Down

0 comments on commit 42ea3b0

Please sign in to comment.