mirror of
https://github.com/godotengine/godot
synced 2024-11-02 11:59:10 +00:00
c5f830d6b9
Code comes from 150e125cba/smaz.c
With a small modification to match Godot expectations:
```
diff --git a/thirdparty/core/smaz.c b/thirdparty/core/smaz.c
index 9b1ebc2..555dfea 100644
--- a/thirdparty/core/smaz.c
+++ b/thirdparty/core/smaz.c
@@ -14,7 +14,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
#include <string.h>
/* Our compression codebook, used for compression */
-static char *Smaz_cb[241] = {
+static const char *Smaz_cb[241] = {
"\002s,\266", "\003had\232\002leW", "\003on \216", "", "\001yS",
"\002ma\255\002li\227", "\003or \260", "", "\002ll\230\003s t\277",
"\004fromg\002mel", "", "\003its\332", "\001z\333", "\003ingF", "\001>\336",
@@ -89,7 +89,7 @@ static char *Smaz_rcb[254] = {
"e, ", " it", "whi", " ma", "ge", "x", "e c", "men", ".com"
};
-int smaz_compress(char *in, int inlen, char *out, int outlen) {
+int smaz_compress(const char *in, int inlen, char *out, int outlen) {
unsigned int h1,h2,h3=0;
int verblen = 0, _outlen = outlen;
char verb[256], *_out = out;
@@ -167,7 +167,7 @@ out:
return out-_out;
}
-int smaz_decompress(char *in, int inlen, char *out, int outlen) {
+int smaz_decompress(const char *in, int inlen, char *out, int outlen) {
unsigned char *c = (unsigned char*) in;
char *_out = out;
int _outlen = outlen;
@@ -192,7 +192,7 @@ int smaz_decompress(char *in, int inlen, char *out, int outlen) {
inlen -= 2+len;
} else {
/* Codebook entry */
- char *s = Smaz_rcb[*c];
+ const char *s = Smaz_rcb[*c];
int len = strlen(s);
if (outlen < len) return _outlen+1;
diff --git a/thirdparty/core/smaz.h b/thirdparty/core/smaz.h
index a547d89..a9d8a33 100644
--- a/thirdparty/core/smaz.h
+++ b/thirdparty/core/smaz.h
@@ -14,7 +14,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
#ifndef _SMAZ_H
#define _SMAZ_H
-int smaz_compress(char *in, int inlen, char *out, int outlen);
-int smaz_decompress(char *in, int inlen, char *out, int outlen);
+int smaz_compress(const char *in, int inlen, char *out, int outlen);
+int smaz_decompress(const char *in, int inlen, char *out, int outlen);
#endif
```
20 lines
1.6 KiB
C++
20 lines
1.6 KiB
C++
/*
|
|
Copyright (c) 2006-2009, Salvatore Sanfilippo
|
|
All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
|
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
* Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#ifndef _SMAZ_H
|
|
#define _SMAZ_H
|
|
|
|
int smaz_compress(const char *in, int inlen, char *out, int outlen);
|
|
int smaz_decompress(const char *in, int inlen, char *out, int outlen);
|
|
|
|
#endif
|