Skip to content
Myr

more warnings, use stdint.h if possible

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent 70df496 · Browse files · 1 file+28 added−16 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+28 added−16 removed

  • other:+28 added−16 removed

1 file+28 added−16 removed

modified:stb_image.c+28 added-16 removed
55 unmodified lines
56 Thomas Ruf57 John Bartholomew58 Optimizations & bugfixes Ken Hamada59 Fabian "ryg" Giesen Cort Stratton60 Blazej Dariusz Roszkowski61 Thibault Reuille62 If your name should be here but Paul Du Bois63 isn't let Sean know. Guillaume George6461 62 If your name should be here but isn't, let Sean know.6365*/6667#ifndef STBI_INCLUDE_STB_IMAGE_H68#define STBI_INCLUDE_STB_IMAGE_H
280 unmodified lines
349#include <stdlib.h>350#include <memory.h>351#include <assert.h>352#include <stdarg.h>353#include <stddef.h> // ptrdiff_t on osx354355#ifndef _MSC_VER356 #ifdef __cplusplus357 #define stbi_inline inline
4 unmodified lines
362 #define stbi_inline __forceinline363#endif364365364// implementation:366#ifdef _MSC_VER367typedef unsigned char stbi__uint8;368typedef unsigned short stbi__uint16;367typedef signed short stbi__int16;369typedef signed short stbi__int16;370typedef unsigned int stbi__uint32;369typedef signed int stbi__int32;371typedef signed int stbi__int32;372#else373#include <stdint.h>374typedef uint8_t stbi__uint8;375typedef uint16_t stbi__uint16;376typedef int16_t stbi__int16;377typedef uint32_t stbi__uint32;378typedef int32_t stbi__int32;379#endif380381// should produce compiler error if size is wrong382typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];383
352 unmodified lines
736static void refill_buffer(stbi *s)737{738 int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen);739 if (n == 0) {730 // at end of file, treat same as if from memory, but need731 // to handle case where s->img_buffer isn't pointing to safe memory740 // at end of file, treat same as if from memory, but need to handle case741 // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file742 s->read_from_callbacks = 0;743 s->img_buffer = s->buffer_start;744 s->img_buffer_end = s->buffer_start+1;745 *s->img_buffer = 0;
2277 unmodified lines
3023 mg = 0xffu << 8;3024 mb = 0xffu << 0;3025 ma = 0xffu << 24;3026 fake_a = 1; // @TODO: check for cases like alpha value is all 0 and switch it to 2553027 STBI_UNUSED(fake_a);3028 } else {3029 mr = 31u << 10;3030 mg = 31u << 5;3031 mb = 31u << 0;
83 unmodified lines
3115 if (!easy) {3116 if (!mr || !mg || !mb) { free(out); return epuc("bad masks", "Corrupt BMP"); }3117 // right shift amt to put high bit in position #73118 rshift = high_bit(mr)-7; rcount = bitcount(mr);3108 gshift = high_bit(mg)-7; gcount = bitcount(mr);3109 bshift = high_bit(mb)-7; bcount = bitcount(mr);3110 ashift = high_bit(ma)-7; acount = bitcount(mr);3119 gshift = high_bit(mg)-7; gcount = bitcount(mg);3120 bshift = high_bit(mb)-7; bcount = bitcount(mb);3121 ashift = high_bit(ma)-7; acount = bitcount(ma);3122 }3123 for (j=0; j < (int) s->img_y; ++j) {3124 if (easy) {3125 for (i=0; i < (int) s->img_x; ++i) {
6 unmodified lines
3132 if (target == 4) out[z++] = (stbi__uint8) a;3133 }3134 } else {3135 for (i=0; i < (int) s->img_x; ++i) {3125 stbi__uint32 v = (bpp == 16 ? get16le(s) : get32le(s));3136 stbi__uint32 v = (stbi_uint32) (bpp == 16 ? get16le(s) : get32le(s));3137 int a;3138 out[z++] = (stbi__uint8) shiftsigned(v & mr, rshift, rcount);3139 out[z++] = (stbi__uint8) shiftsigned(v & mg, gshift, gcount);3140 out[z++] = (stbi__uint8) shiftsigned(v & mb, bshift, bcount);
1178 unmodified lines
4319 // can't use sscanf() if we're not using stdio!4320 token = hdr_gettoken(s,buffer);4321 if (strncmp(token, "-Y ", 3)) return epf("unsupported data layout", "Unsupported HDR format");4322 token += 3;4312 height = strtol(token, &token, 10);4323 height = (int) strtol(token, &token, 10);4324 while (*token == ' ') ++token;4325 if (strncmp(token, "+X ", 3)) return epf("unsupported data layout", "Unsupported HDR format");4326 token += 3;4316 width = strtol(token, NULL, 10);4327 width = (int) strtol(token, NULL, 10);43284329 *x = width;4330 *y = height;4331
99 unmodified lines
4431 stbi_rewind( s );4432 return 0;4433 }4434 token += 3;4424 *y = strtol(token, &token, 10);4435 *y = (int) strtol(token, &token, 10);4436 while (*token == ' ') ++token;4437 if (strncmp(token, "+X ", 3)) {4438 stbi_rewind( s );4439 return 0;4440 }4441 token += 3;4431 *x = strtol(token, NULL, 10);4442 *x = (int) strtol(token, NULL, 10);4443 *comp = 3;4444 return 1;4445}4446#endif // STBI_NO_HDR
175 unmodified lines
4622 1.35 (2014-05-27)4623 various warnings4624 fix broken STBI_SIMD path4625 fix bug where stbi_load_from_file no longer left file pointer in correct place4626 fix broken non-easy path for 32-bit BMP (possibly never used)4627 1.34 (unknown)4628 use STBI_NOTUSED in resample_row_generic(), fix one more leak in tga failure case4629 1.33 (2011-07-14)4630 make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements
82 unmodified lines