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
|
#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.
|
Decompresses the source buffer into the destination buffer.
|
||||||
Returns the size of the uncompressed data (number of bytes written starting
|
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,
|
int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
|
||||||
const char* source, unsigned sourceLen);
|
const unsigned char* source, unsigned sourceLen);
|
||||||
/*
|
/*
|
||||||
Original zlib description:
|
Original zlib description:
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
;
|
;
|
||||||
; 2017-11-07, Piotr Fusik
|
; 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
|
; NOTE: Be extremely careful with modifications, because this code is heavily
|
||||||
; optimized for size (for example assumes certain register and flag values
|
; optimized for size (for example assumes certain register and flag values
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
int __fastcall__ uncompress (char* dest, unsigned* destLen,
|
int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
|
||||||
const char* source, unsigned sourceLen)
|
const unsigned char* source, unsigned sourceLen)
|
||||||
{
|
{
|
||||||
unsigned len;
|
unsigned len;
|
||||||
unsigned char* ptr;
|
const unsigned char* ptr = source + sourceLen - 4;
|
||||||
unsigned long csum;
|
unsigned long csum;
|
||||||
/* source[0]: Compression method and flags
|
/* source[0]: Compression method and flags
|
||||||
bits 0 to 3: Compression method (must be Z_DEFLATED)
|
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)
|
if ((source[0] & 0x8f) != Z_DEFLATED || source[1] & 0x20)
|
||||||
return Z_DATA_ERROR;
|
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;
|
return Z_DATA_ERROR;
|
||||||
*destLen = len = inflatemem(dest, source + 2);
|
*destLen = len = inflatemem(dest, source + 2);
|
||||||
ptr = (unsigned char*) source + sourceLen - 4;
|
|
||||||
csum = adler32(adler32(0L, Z_NULL, 0), dest, len);
|
csum = adler32(adler32(0L, Z_NULL, 0), dest, len);
|
||||||
if ((unsigned char) csum != ptr[3]
|
if ((unsigned char) csum != ptr[3]
|
||||||
|| (unsigned char) (csum >> 8) != ptr[2]
|
|| (unsigned char) (csum >> 8) != ptr[2]
|
||||||
|
Loading…
Reference in New Issue
Block a user