Skip to content
Myr

Merge branch 'unused-function-warnings' of https://github.com/BradleyMarie/stb into work2

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 · parents d256911, e2b8524 · Browse files · 3 files+48 added−5 removed
This commit

State

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

Diff stats

3 files+48 added−5 removed

  • other:+48 added−5 removed

3 files+48 added−5 removed

modified:.github/CONTRIBUTING.md+3 added
modified:stb_image.h+43 added-3 removed
103 unmodified lines
104 Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw105 Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus106 Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo107 Christian Floisand Kevin Schmidt JR Smith github:darealshinji108 Blazej Dariusz Roszkowski github:Michaelangel007109 Matvey Cherevko108 Brad Weinberger Matvey Cherevko github:Michaelangel007109 Blazej Dariusz Roszkowski110 111*/112113#ifndef STBI_INCLUDE_STB_IMAGE_H114#define STBI_INCLUDE_STB_IMAGE_H
829 unmodified lines
944 // portable way to check for no overflows in a*b945 return a <= INT_MAX/b;946}947948#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)949// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow950static int stbi__mad2sizes_valid(int a, int b, int add)951{952 return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add);953}954#endif955956// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow957static int stbi__mad3sizes_valid(int a, int b, int c, int add)958{
9 unmodified lines
968 stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);969}970#endif971972#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)973// mallocs with size overflow checking974static void *stbi__malloc_mad2(int a, int b, int add)975{976 if (!stbi__mad2sizes_valid(a, b, add)) return NULL;977 return stbi__malloc(a*b + add);978}979#endif980981static void *stbi__malloc_mad3(int a, int b, int c, int add)982{983 if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL;
535 unmodified lines
1519 }1520 return 0;1521}15221523#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)1524// nothing1525#else1526stbi_inline static int stbi__at_eof(stbi__context *s)1527{1528 if (s->io.read) {1529 if (!(s->io.eof)(s->io_user_data)) return 0;
3 unmodified lines
1533 }15341535 return s->img_buffer >= s->img_buffer_end;1536}1537#endif15381539#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC)1540// nothing1541#else1542static void stbi__skip(stbi__context *s, int n)1543{1544 if (n < 0) {1545 s->img_buffer = s->img_buffer_end;
8 unmodified lines
1554 }1555 }1556 s->img_buffer += n;1557}1558#endif15591560#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM)1561// nothing1562#else1563static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n)1564{1565 if (s->io.read) {1566 int blen = (int) (s->img_buffer_end - s->img_buffer);
15 unmodified lines
1582 return 1;1583 } else1584 return 0;1585}1586#endif15871588#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)1589// nothing1590#else1591static int stbi__get16be(stbi__context *s)1592{1593 int z = stbi__get8(s);1594 return (z << 8) + stbi__get8(s);1595}1596#endif15971598#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)1599// nothing1600#else1601static stbi__uint32 stbi__get32be(stbi__context *s)1602{1603 stbi__uint32 z = stbi__get16be(s);1604 return (z << 16) + stbi__get16be(s);1605}1606#endif16071608#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF)1609// nothing1610#else
13 unmodified lines
1624#endif16251626#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings162716031628#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)1629// nothing1630#else1631//////////////////////////////////////////////////////////////////////////////1632//1633// generic converter from built-in img_n to req_comp1634// individual types do this automatically as much as possible (e.g. jpeg
7 unmodified lines
1642static stbi_uc stbi__compute_y(int r, int g, int b)1643{1644 return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8);1645}1646#endif16471648#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)1649// nothing1650#else1651static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)1652{1653 int i,j;1654 unsigned char *good;
35 unmodified lines
16901691 STBI_FREE(data);1692 return good;1693}1694#endif16951696#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)1697// nothing1698#else1699static stbi__uint16 stbi__compute_y_16(int r, int g, int b)1700{1701 return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8);1702}1703#endif17041705#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)1706// nothing1707#else1708static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)1709{1710 int i,j;1711 stbi__uint16 *good;
35 unmodified lines
17471748 STBI_FREE(data);1749 return good;1750}1751#endif17521753#ifndef STBI_NO_LINEAR1754static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp)1755{
5898 unmodified lines
modified:stb.h+2 added-2 removed
2452 unmodified lines
2453 buffer = (char *) malloc(y-x + len + 1);2454 if (!buffer) return NULL;2455 }24562457 if (len) { stb_p_strcpy_s(buffer, sizeof(buffer), "./"); return buffer; }2458 stb_strncpy(buffer, path+int(x), int(y-x));2457 if (len) { stb_p_strcpy_s(buffer, 3, "./"); return buffer; }2458 stb_strncpy(buffer, path+(int)x, (int)(y-x));2459 return buffer;2460}24612462char *stb_splitpath(char *output, char *src, int flag)
11992 unmodified lines