mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
zlib: Use correct (un)signedness of char in prototypes and functions.
Also ensure we are using the same constness qualifiers.
This commit is contained in:
parent
e0ac9d5d8e
commit
93b6efcb2f
@ -48,7 +48,8 @@
|
||||
#define Z_NULL 0
|
||||
|
||||
|
||||
unsigned __fastcall__ inflatemem (char* dest, const char* source);
|
||||
unsigned __fastcall__ inflatemem (unsigned char* dest,
|
||||
const unsigned char* source);
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer.
|
||||
Returns the size of the uncompressed data (number of bytes written starting
|
||||
@ -83,8 +84,8 @@ unsigned __fastcall__ inflatemem (char* dest, const char* source);
|
||||
*/
|
||||
|
||||
|
||||
int __fastcall__ uncompress (char* dest, unsigned* destLen,
|
||||
const char* source, unsigned sourceLen);
|
||||
int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
|
||||
const unsigned char* source, unsigned sourceLen);
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
;
|
||||
; 2017-11-07, Piotr Fusik
|
||||
;
|
||||
; unsigned __fastcall__ inflatemem (char* dest, const char* source);
|
||||
; unsigned __fastcall__ inflatemem (unsigned char* dest,
|
||||
; const unsigned char* source);
|
||||
;
|
||||
; NOTE: Be extremely careful with modifications, because this code is heavily
|
||||
; optimized for size (for example assumes certain register and flag values
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
int __fastcall__ uncompress (char* dest, unsigned* destLen,
|
||||
const char* source, unsigned sourceLen)
|
||||
int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
|
||||
const unsigned char* source, unsigned sourceLen)
|
||||
{
|
||||
unsigned len;
|
||||
unsigned char* ptr;
|
||||
const unsigned char* ptr = source + sourceLen - 4;
|
||||
unsigned long csum;
|
||||
/* source[0]: Compression method and flags
|
||||
bits 0 to 3: Compression method (must be Z_DEFLATED)
|
||||
@ -22,10 +22,9 @@ int __fastcall__ uncompress (char* dest, unsigned* destLen,
|
||||
*/
|
||||
if ((source[0] & 0x8f) != Z_DEFLATED || source[1] & 0x20)
|
||||
return Z_DATA_ERROR;
|
||||
if ((((unsigned) source[0] << 8) | (unsigned char) source[1]) % 31)
|
||||
if ((((unsigned) source[0] << 8) | source[1]) % 31)
|
||||
return Z_DATA_ERROR;
|
||||
*destLen = len = inflatemem(dest, source + 2);
|
||||
ptr = (unsigned char*) source + sourceLen - 4;
|
||||
csum = adler32(adler32(0L, Z_NULL, 0), dest, len);
|
||||
if ((unsigned char) csum != ptr[3]
|
||||
|| (unsigned char) (csum >> 8) != ptr[2]
|
||||
|
Loading…
Reference in New Issue
Block a user