79 _(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
82 return ZSTD_compressBound(src_sz);
89 int err, nbytes, buf_sz;
94 _(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
109 if (src_sz <= 0 || dst_sz <= 0) {
111 G_warning(
_(
"Invalid source buffer size %d"), src_sz);
113 G_warning(
_(
"Invalid destination buffer size %d"), dst_sz);
120 if (buf_sz > dst_sz) {
122 "G_zstd_compress(): programmer error, destination is too small");
124 (buf = (
unsigned char *)
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 ZSTD_getErrorName(
err));
169 _(
"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 ZSTD_getErrorName(
err));
204 if (nbytes != dst_sz) {
206 G_warning(
_(
"Got uncompressed size %d, expected %d"), (
int)nbytes,
int G_zstd_compress_bound(int src_sz)
int G_zstd_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
int G_zstd_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)