summaryrefslogtreecommitdiff
path: root/test/inflate-app.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/inflate-app.c')
-rw-r--r--test/inflate-app.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/inflate-app.c b/test/inflate-app.c
new file mode 100644
index 0000000..dddc807
--- /dev/null
+++ b/test/inflate-app.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "inflate.h"
+
+unsigned char *inbuf;
+unsigned char *outbuf;
+
+int main(void)
+{
+ // 16 MB
+ inbuf = malloc(4096 * 4096);
+ outbuf = malloc(4096 * 4096);
+
+ if (inbuf == NULL || outbuf == NULL) {
+ return 1;
+ }
+
+ size_t in_size = fread(inbuf, 1, 4096 * 4096, stdin);
+
+ if (in_size == 0) {
+ return 1;
+ }
+
+ int16_t out_size = inflate_zlib(inbuf, in_size, outbuf, 65535);
+
+ if (out_size < 0) {
+ return -out_size;
+ }
+
+ fwrite(outbuf, 1, out_size, stdout);
+
+ return 0;
+}