summaryrefslogtreecommitdiffhomepage
path: root/src/external/sinfl.h
diff options
context:
space:
mode:
authorRay <[email protected]>2023-06-30 09:47:16 +0200
committerRay <[email protected]>2023-06-30 09:47:16 +0200
commite190b7eee9199b681a8c50fb69f2fce07e92c7af (patch)
treec1ae19e06803c741002fdef40cf235d8dbae206d /src/external/sinfl.h
parentceafbcf9d2d722886c40d0ba12eaad2f232a2782 (diff)
downloadraylib-e190b7eee9199b681a8c50fb69f2fce07e92c7af.tar.gz
raylib-e190b7eee9199b681a8c50fb69f2fce07e92c7af.zip
UPDATED: `sdefl` and `sinfl` compression libraries
Diffstat (limited to 'src/external/sinfl.h')
-rw-r--r--src/external/sinfl.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/external/sinfl.h b/src/external/sinfl.h
index 915da9d2..8979fcd7 100644
--- a/src/external/sinfl.h
+++ b/src/external/sinfl.h
@@ -72,7 +72,7 @@ Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
+Copyright (c) 2020-2023 Micha Mettke
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
@@ -400,17 +400,21 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
} break;
case stored: {
/* uncompressed block */
- int len, nlen;
- sinfl_refill(&s);
+ unsigned len, nlen;
sinfl__get(&s,s.bitcnt & 7);
- len = sinfl__get(&s,16);
- nlen = sinfl__get(&s,16);
- in -= 2; s.bitcnt = 0;
+ len = (unsigned short)sinfl__get(&s,16);
+ nlen = (unsigned short)sinfl__get(&s,16);
+ s.bitptr -= s.bitcnt / 8;
+ s.bitbuf = s.bitcnt = 0;
- if (len > (e-in) || !len)
+ if ((unsigned short)len != (unsigned short)~nlen)
+ return (int)(out-o);
+ if (len > (e - s.bitptr) || !len)
return (int)(out-o);
- memcpy(out, in, (size_t)len);
- in += len, out += len;
+
+ memcpy(out, s.bitptr, (size_t)len);
+ s.bitptr += len, out += len;
+ if (last) return (int)(out-o);
state = hdr;
} break;
case fixed: {
@@ -443,8 +447,9 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
/* decode code lengths */
for (n = 0; n < nlit + ndist;) {
+ int sym = 0;
sinfl_refill(&s);
- int sym = sinfl_decode(&s, hlens, 7);
+ sym = sinfl_decode(&s, hlens, 7);
switch (sym) {default: lens[n++] = (unsigned char)sym; break;
case 16: for (i=3+sinfl_get(&s,2);i;i--,n++) lens[n]=lens[n-1]; break;
case 17: for (i=3+sinfl_get(&s,3);i;i--,n++) lens[n]=0; break;
@@ -458,8 +463,9 @@ sinfl_decompress(unsigned char *out, int cap, const unsigned char *in, int size)
case blk: {
/* decompress block */
while (1) {
+ int sym;
sinfl_refill(&s);
- int sym = sinfl_decode(&s, s.lits, 10);
+ sym = sinfl_decode(&s, s.lits, 10);
if (sym < 256) {
/* literal */
if (sinfl_unlikely(out >= oe)) {