diff options
Diffstat (limited to 'src/zlib.c')
-rw-r--r-- | src/zlib.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/zlib.c b/src/zlib.c new file mode 100644 index 0000000..49004b7 --- /dev/null +++ b/src/zlib.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020, yzrh <yzrh@noema.org> + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include <stdlib.h> +#include <string.h> + +#include <zlib.h> + +int +strinflate(char **dst, int dst_size, + const char * restrict src, int src_size) +{ + *dst = malloc(dst_size); + + if (*dst == NULL) + return 1; + + unsigned long size = dst_size; + + uncompress((Bytef *) *dst, &size, (const Bytef *) src, src_size); + + if (size != dst_size) { + free(*dst); + return 1; + } + + return 0; +} |