80 G_fatal_error(
_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
83 return ZSTD_compressBound(src_sz);
91 int err, nbytes, buf_sz;
95 G_fatal_error(
_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
110 if (src_sz <= 0 || dst_sz <= 0) {
112 G_warning(
_(
"Invalid source buffer size %d"), src_sz);
114 G_warning(
_(
"Invalid destination buffer size %d"), dst_sz);
121 if (buf_sz > dst_sz) {
122 G_warning(
"G_zstd_compress(): programmer error, destination is too small");
123 if (
NULL == (buf = (
unsigned char *)
124 G_calloc(buf_sz,
sizeof(
unsigned char))))
131 err = ZSTD_compress((
char *)buf, buf_sz, (
char *)src, src_sz, 3);
133 if (err <= 0 || ZSTD_isError(err)) {
135 err, ZSTD_getErrorName(err));
152 for (err = 0; err < nbytes; err++)
169 G_fatal_error(
_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
184 if (src_sz <= 0 || dst_sz <= 0) {
186 G_warning(
_(
"Invalid source buffer size %d"), src_sz);
188 G_warning(
_(
"Invalid destination buffer size %d"), dst_sz);
193 err = ZSTD_decompress((
char *)dst, dst_sz, (
char *)src, src_sz);
195 if (err <= 0 || ZSTD_isError(err)) {
197 err, ZSTD_getErrorName(err));
204 if (nbytes != dst_sz) {
206 G_warning(
_(
"Got uncompressed size %d, expected %d"), (
int)nbytes, dst_sz);
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_zstd_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
void G_free(void *)
Free allocated memory.
int G_zstd_compress_bound(int src_sz)
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int G_zstd_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
void G_warning(const char *,...) __attribute__((format(printf