diff options
author | yzrh <yzrh@noema.org> | 2020-12-30 03:09:00 +0000 |
---|---|---|
committer | yzrh <yzrh@noema.org> | 2020-12-30 03:09:00 +0000 |
commit | 98691d4203f4e578b84b2014db0fbe0c1209cc48 (patch) | |
tree | c528e3ea964111b934ae5e61e847831d62944f41 /src/zlib.c | |
parent | 8d6fbb43c9bc840d4217bf4f0b49b1213f1601a1 (diff) | |
download | melon-98691d4203f4e578b84b2014db0fbe0c1209cc48.tar.gz melon-98691d4203f4e578b84b2014db0fbe0c1209cc48.tar.zst |
Add HN text extraction.
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; +} |