add missing consts
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by fahickman · committed by fahickman · parent e0e4bd4 · Browse files · 1 file·+21 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+21 added−21 removed
- other:+21 added−21 removed
Provenance
- Commit
126ec22- Tree
3c65472- Author
fahickman <f.alan.hickman@gmail.com>- Committer
fahickman <f.alan.hickman@gmail.com>- Parent
e0e4bd4
1 file changed+21 added−21 removed
modified:stb_image_write.h+21 added-21 removed
256 unmodified lines257 258 writef(f, "111 221 2222 11", 0,0,format, 0,0,0, 0,0,x,y, 24+8*has_alpha, 8*has_alpha);259 260 for (j = y - 1; j >= 0; --j) {261- unsigned char *line = (unsigned char *) data + j * x * comp;262- int run;261+ const unsigned char *row = (unsigned char *) data + j * x * comp;262+ int len;263 264- for (i = 0; i < x; i += run) {265- unsigned char *first = line + i * comp;264+ for (i = 0; i < x; i += len) {265+ const unsigned char *begin = row + i * comp;266 int diff = 1;267- run = 1;267+ len = 1;268 269 if (i < x - 1) {270- ++run;271- diff = memcmp(first, line + (i + 1) * comp, comp);270+ ++len;271+ diff = memcmp(begin, row + (i + 1) * comp, comp);272 if (diff) {273- unsigned char *next = first;274- for (k = i + 2; k < x && run < 128; ++k) {275- if (memcmp(next, line + k * comp, comp)) {276- next += comp;277- ++run;273+ const unsigned char *prev = begin;274+ for (k = i + 2; k < x && len < 128; ++k) {275+ if (memcmp(prev, row + k * comp, comp)) {276+ prev += comp;277+ ++len;278 } else {279- --run;279+ --len;280 break;281 }282 }283 } else {284- for (k = i + 2; k < x && run < 128; ++k) {285- if (!memcmp(first, line + k * comp, comp)) {286- ++run;284+ for (k = i + 2; k < x && len < 128; ++k) {285+ if (!memcmp(begin, row + k * comp, comp)) {286+ ++len;287 } else {288 break;289 }290 }291 }292 }293 294 if (diff) {295- unsigned char header = (unsigned char) (run - 1);295+ unsigned char header = (unsigned char) (len - 1);296 fwrite(&header, 1, 1, f);297- for (k = 0; k < run; ++k) {298- write_pixel(f, -1, comp, has_alpha, 0, first + k * comp);297+ for (k = 0; k < len; ++k) {298+ write_pixel(f, -1, comp, has_alpha, 0, begin + k * comp);299 }300 } else {301- unsigned char header = (unsigned char) (run - 1) | 0x80;301+ unsigned char header = (unsigned char) (len - 129);302 fwrite(&header, 1, 1, f);303- write_pixel(f, -1, comp, has_alpha, 0, first);303+ write_pixel(f, -1, comp, has_alpha, 0, begin);304 }305 }306 }307 497 unmodified lines