67 #error "GRASS requires libz to compile" 87 return compressBound(src_sz);
94 uLong
err, nbytes, buf_sz;
108 if (src_sz <= 0 || dst_sz <= 0) {
110 G_warning(
_(
"Invalid source buffer size %d"), src_sz);
112 G_warning(
_(
"Invalid destination buffer size %d"), dst_sz);
122 if (buf_sz > dst_sz) {
123 G_warning(
"G_zlib_compress(): programmer error, destination is too small");
124 if (
NULL == (buf = (
unsigned char *)
125 G_calloc(buf_sz,
sizeof(
unsigned char))))
137 err = compress2((Bytef *)buf, &nbytes,
138 (
const Bytef *)src, src_sz,
143 (
int)err, zError(err));
150 if (nbytes >= src_sz) {
159 for (err = 0; err < nbytes; err++)
187 if (src_sz <= 0 || dst_sz <= 0) {
189 G_warning(
_(
"Invalid source buffer size %d"), src_sz);
191 G_warning(
_(
"Invalid destination buffer size %d"), dst_sz);
199 err = uncompress((Bytef *)dst, &nbytes,
200 (
const Bytef *)src, ss);
204 G_warning(
_(
"ZLIB decompression error %d: %s"),
213 if (nbytes != dst_sz) {
215 G_warning(
_(
"Got uncompressed size %d, expected %d"), (
int)nbytes, dst_sz);
void G_free(void *)
Free allocated memory.
int G_zlib_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int G_zlib_compress_bound(int src_sz)
void G_warning(const char *,...) __attribute__((format(printf
int G_zlib_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)