Merge branch 'working'
This commit is contained in:
commit
9092c0487d
@ -4792,7 +4792,7 @@ static void stbi__de_iphone(stbi__png *z)
|
|||||||
static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
|
static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
|
||||||
{
|
{
|
||||||
stbi_uc palette[1024], pal_img_n=0;
|
stbi_uc palette[1024], pal_img_n=0;
|
||||||
stbi_uc has_trans=0, tc[3];
|
stbi_uc has_trans=0, tc[3]={0};
|
||||||
stbi__uint16 tc16[3];
|
stbi__uint16 tc16[3];
|
||||||
stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;
|
stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;
|
||||||
int first=1,k,interlace=0, color=0, is_iphone=0;
|
int first=1,k,interlace=0, color=0, is_iphone=0;
|
||||||
|
@ -58,8 +58,8 @@ void stb_leakcheck_free(void *ptr)
|
|||||||
mi->prev->next = mi->next;
|
mi->prev->next = mi->next;
|
||||||
if (mi->next)
|
if (mi->next)
|
||||||
mi->next->prev = mi->prev;
|
mi->next->prev = mi->prev;
|
||||||
#endif
|
|
||||||
free(mi);
|
free(mi);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,21 +89,25 @@ void *stb_leakcheck_realloc(void *ptr, size_t sz, const char *file, int line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stblkck_internal_print(const char *reason, const char *file, int line, size_t size, void *ptr)
|
static void stblkck_internal_print(const char *reason, stb_leakcheck_malloc_info *mi)
|
||||||
{
|
{
|
||||||
#if (defined(_MSC_VER) && _MSC_VER < 1900) /* 1900=VS 2015 */ || defined(__MINGW32__)
|
#if defined(_MSC_VER) && _MSC_VER < 1900 // 1900=VS 2015
|
||||||
// Compilers that use the old MS C runtime library don't have %zd
|
// Compilers that use the old MS C runtime library don't have %zd
|
||||||
// and the older ones don't even have %lld either... however, the old compilers
|
// and the older ones don't even have %lld either... however, the old compilers
|
||||||
// without "long long" don't support 64-bit targets either, so here's the
|
// without "long long" don't support 64-bit targets either, so here's the
|
||||||
// compromise:
|
// compromise:
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1400 // before VS 2005
|
#if _MSC_VER < 1400 // before VS 2005
|
||||||
printf("%-6s: %s (%4d): %8d bytes at %p\n", reason, file, line, (int)size, ptr);
|
printf("%s: %s (%4d): %8d bytes at %p\n", reason, mi->file, mi->line, (int)mi->size, (void*)(mi+1));
|
||||||
#else
|
#else
|
||||||
printf("%-6s: %s (%4d): %8lld bytes at %p\n", reason, file, line, (long long)size, ptr);
|
printf("%s: %s (%4d): %16lld bytes at %p\n", reason, mi->file, mi->line, (long long)mi->size, (void*)(mi+1));
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// Assume we have %zd on other targets.
|
// Assume we have %zd on other targets.
|
||||||
printf("%-6s: %s (%4d): %zd bytes at %p\n", reason, file, line, size, ptr);
|
#ifdef __MINGW32__
|
||||||
|
__mingw_printf("%s: %s (%4d): %zd bytes at %p\n", reason, mi->file, mi->line, mi->size, (void*)(mi+1));
|
||||||
|
#else
|
||||||
|
printf("%s: %s (%4d): %zd bytes at %p\n", reason, mi->file, mi->line, mi->size, (void*)(mi+1));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,16 +116,14 @@ void stb_leakcheck_dumpmem(void)
|
|||||||
stb_leakcheck_malloc_info *mi = mi_head;
|
stb_leakcheck_malloc_info *mi = mi_head;
|
||||||
while (mi) {
|
while (mi) {
|
||||||
if ((ptrdiff_t) mi->size >= 0)
|
if ((ptrdiff_t) mi->size >= 0)
|
||||||
stblkck_internal_print("LEAKED", mi->file, mi->line, mi->size, mi+1);
|
stblkck_internal_print("LEAKED", mi);
|
||||||
printf("LEAKED: %s (%4d): %8d bytes at %p\n", mi->file, mi->line, (int) mi->size, mi+1);
|
|
||||||
mi = mi->next;
|
mi = mi->next;
|
||||||
}
|
}
|
||||||
#ifdef STB_LEAKCHECK_SHOWALL
|
#ifdef STB_LEAKCHECK_SHOWALL
|
||||||
mi = mi_head;
|
mi = mi_head;
|
||||||
while (mi) {
|
while (mi) {
|
||||||
if ((ptrdiff_t) mi->size < 0)
|
if ((ptrdiff_t) mi->size < 0)
|
||||||
stblkck_internal_print("FREED", mi->file, mi->line, ~mi->size, mi+1);
|
stblkck_internal_print("FREED ", mi);
|
||||||
printf("FREED : %s (%4d): %8d bytes at %p\n", mi->file, mi->line, (int) ~mi->size, mi+1);
|
|
||||||
mi = mi->next;
|
mi = mi->next;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -131,6 +133,8 @@ void stb_leakcheck_dumpmem(void)
|
|||||||
#ifndef INCLUDE_STB_LEAKCHECK_H
|
#ifndef INCLUDE_STB_LEAKCHECK_H
|
||||||
#define INCLUDE_STB_LEAKCHECK_H
|
#define INCLUDE_STB_LEAKCHECK_H
|
||||||
|
|
||||||
|
#include <stdlib.h> // we want to define the macros *after* stdlib to avoid a slew of errors
|
||||||
|
|
||||||
#define malloc(sz) stb_leakcheck_malloc(sz, __FILE__, __LINE__)
|
#define malloc(sz) stb_leakcheck_malloc(sz, __FILE__, __LINE__)
|
||||||
#define free(p) stb_leakcheck_free(p)
|
#define free(p) stb_leakcheck_free(p)
|
||||||
#define realloc(p,sz) stb_leakcheck_realloc(p,sz, __FILE__, __LINE__)
|
#define realloc(p,sz) stb_leakcheck_realloc(p,sz, __FILE__, __LINE__)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
// Marcin Wojdyr
|
// Marcin Wojdyr
|
||||||
// Leonard Ritter
|
// Leonard Ritter
|
||||||
// Stefano Zanotti
|
// Stefano Zanotti
|
||||||
|
// Adam Allison
|
||||||
//
|
//
|
||||||
// LICENSE:
|
// LICENSE:
|
||||||
//
|
//
|
||||||
@ -226,11 +227,18 @@ static stbsp__int32 stbsp__real_to_parts(stbsp__int64 *bits, stbsp__int32 *expo,
|
|||||||
|
|
||||||
static char stbsp__period = '.';
|
static char stbsp__period = '.';
|
||||||
static char stbsp__comma = ',';
|
static char stbsp__comma = ',';
|
||||||
static char stbsp__digitpair[201] =
|
static struct
|
||||||
|
{
|
||||||
|
short temp; // force next field to be 2-byte aligned
|
||||||
|
char pair[201];
|
||||||
|
} stbsp__digitpair =
|
||||||
|
{
|
||||||
|
0,
|
||||||
"00010203040506070809101112131415161718192021222324"
|
"00010203040506070809101112131415161718192021222324"
|
||||||
"25262728293031323334353637383940414243444546474849"
|
"25262728293031323334353637383940414243444546474849"
|
||||||
"50515253545556575859606162636465666768697071727374"
|
"50515253545556575859606162636465666768697071727374"
|
||||||
"75767778798081828384858687888990919293949596979899";
|
"75767778798081828384858687888990919293949596979899"
|
||||||
|
};
|
||||||
|
|
||||||
STBSP__PUBLICDEF void STB_SPRINTF_DECORATE(set_separators)(char pcomma, char pperiod)
|
STBSP__PUBLICDEF void STB_SPRINTF_DECORATE(set_separators)(char pcomma, char pperiod)
|
||||||
{
|
{
|
||||||
@ -687,7 +695,7 @@ STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback,
|
|||||||
if (dp > 0) {
|
if (dp > 0) {
|
||||||
pr = (dp < (stbsp__int32)l) ? l - dp : 0;
|
pr = (dp < (stbsp__int32)l) ? l - dp : 0;
|
||||||
} else {
|
} else {
|
||||||
pr = -dp + ((pr > (stbsp__int32)l) ? l : pr);
|
pr = -dp + ((pr > (stbsp__int32)l) ? (stbsp__int32) l : pr);
|
||||||
}
|
}
|
||||||
goto dofloatfromg;
|
goto dofloatfromg;
|
||||||
|
|
||||||
@ -1047,7 +1055,7 @@ STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback,
|
|||||||
if ((fl & STBSP__TRIPLET_COMMA) == 0) {
|
if ((fl & STBSP__TRIPLET_COMMA) == 0) {
|
||||||
do {
|
do {
|
||||||
s -= 2;
|
s -= 2;
|
||||||
*(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair[(n % 100) * 2];
|
*(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair.pair[(n % 100) * 2];
|
||||||
n /= 100;
|
n /= 100;
|
||||||
} while (n);
|
} while (n);
|
||||||
}
|
}
|
||||||
@ -1445,7 +1453,7 @@ static stbsp__int32 stbsp__real_to_parts(stbsp__int64 *bits, stbsp__int32 *expo,
|
|||||||
*bits = b & ((((stbsp__uint64)1) << 52) - 1);
|
*bits = b & ((((stbsp__uint64)1) << 52) - 1);
|
||||||
*expo = (stbsp__int32)(((b >> 52) & 2047) - 1023);
|
*expo = (stbsp__int32)(((b >> 52) & 2047) - 1023);
|
||||||
|
|
||||||
return (stbsp__int32)(b >> 63);
|
return (stbsp__int32)((stbsp__uint64) b >> 63);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double const stbsp__bot[23] = {
|
static double const stbsp__bot[23] = {
|
||||||
@ -1655,7 +1663,7 @@ static stbsp__int32 stbsp__real_to_str(char const **start, stbsp__uint32 *len, c
|
|||||||
d = value;
|
d = value;
|
||||||
STBSP__COPYFP(bits, d);
|
STBSP__COPYFP(bits, d);
|
||||||
expo = (stbsp__int32)((bits >> 52) & 2047);
|
expo = (stbsp__int32)((bits >> 52) & 2047);
|
||||||
ng = (stbsp__int32)(bits >> 63);
|
ng = (stbsp__int32)((stbsp__uint64) bits >> 63);
|
||||||
if (ng)
|
if (ng)
|
||||||
d = -d;
|
d = -d;
|
||||||
|
|
||||||
@ -1765,7 +1773,7 @@ static stbsp__int32 stbsp__real_to_str(char const **start, stbsp__uint32 *len, c
|
|||||||
}
|
}
|
||||||
while (n) {
|
while (n) {
|
||||||
out -= 2;
|
out -= 2;
|
||||||
*(stbsp__uint16 *)out = *(stbsp__uint16 *)&stbsp__digitpair[(n % 100) * 2];
|
*(stbsp__uint16 *)out = *(stbsp__uint16 *)&stbsp__digitpair.pair[(n % 100) * 2];
|
||||||
n /= 100;
|
n /= 100;
|
||||||
e += 2;
|
e += 2;
|
||||||
}
|
}
|
||||||
|
20
stb_vorbis.c
20
stb_vorbis.c
@ -374,7 +374,8 @@ enum STBVorbisError
|
|||||||
VORBIS_invalid_first_page,
|
VORBIS_invalid_first_page,
|
||||||
VORBIS_bad_packet_type,
|
VORBIS_bad_packet_type,
|
||||||
VORBIS_cant_find_last_page,
|
VORBIS_cant_find_last_page,
|
||||||
VORBIS_seek_failed
|
VORBIS_seek_failed,
|
||||||
|
VORBIS_ogg_skeleton_not_supported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -3578,7 +3579,22 @@ static int start_decoder(vorb *f)
|
|||||||
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
|
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
|
||||||
// check for expected packet length
|
// check for expected packet length
|
||||||
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
|
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
|
||||||
if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page);
|
if (f->segments[0] != 30) {
|
||||||
|
// check for the Ogg skeleton fishead identifying header to refine our error
|
||||||
|
if (f->segments[0] == 64 &&
|
||||||
|
getn(f, header, 6) &&
|
||||||
|
header[0] == 'f' &&
|
||||||
|
header[1] == 'i' &&
|
||||||
|
header[2] == 's' &&
|
||||||
|
header[3] == 'h' &&
|
||||||
|
header[4] == 'e' &&
|
||||||
|
header[5] == 'a' &&
|
||||||
|
get8(f) == 'd' &&
|
||||||
|
get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported);
|
||||||
|
else
|
||||||
|
return error(f, VORBIS_invalid_first_page);
|
||||||
|
}
|
||||||
|
|
||||||
// read packet
|
// read packet
|
||||||
// check packet header
|
// check packet header
|
||||||
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
|
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
|
||||||
|
Loading…
Reference in New Issue
Block a user