summaryrefslogtreecommitdiff
path: root/src/serialization.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-09-14 17:42:08 -0400
committerShadowNinja <shadowninja@minetest.net>2014-09-20 14:02:54 -0400
commit406ed5efac68af31c3cc7a0e7401ebf4dd419804 (patch)
tree377b40c24e5bcd73a773018e10636172c808276e /src/serialization.cpp
parentd6e28c19b59e336f4581682baacb6afb66956f95 (diff)
downloadminetest-406ed5efac68af31c3cc7a0e7401ebf4dd419804.tar.gz
minetest-406ed5efac68af31c3cc7a0e7401ebf4dd419804.tar.bz2
minetest-406ed5efac68af31c3cc7a0e7401ebf4dd419804.zip
Add compression API
Diffstat (limited to 'src/serialization.cpp')
-rw-r--r--src/serialization.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/serialization.cpp b/src/serialization.cpp
index 118bad467..c0fbe10e2 100644
--- a/src/serialization.cpp
+++ b/src/serialization.cpp
@@ -53,7 +53,7 @@ void zerr(int ret)
}
}
-void compressZlib(SharedBuffer<u8> data, std::ostream &os)
+void compressZlib(SharedBuffer<u8> data, std::ostream &os, int level)
{
z_stream z;
const s32 bufsize = 16384;
@@ -65,7 +65,7 @@ void compressZlib(SharedBuffer<u8> data, std::ostream &os)
z.zfree = Z_NULL;
z.opaque = Z_NULL;
- ret = deflateInit(&z, -1);
+ ret = deflateInit(&z, level);
if(ret != Z_OK)
throw SerializationError("compressZlib: deflateInit failed");
@@ -94,13 +94,12 @@ void compressZlib(SharedBuffer<u8> data, std::ostream &os)
}
deflateEnd(&z);
-
}
-void compressZlib(const std::string &data, std::ostream &os)
+void compressZlib(const std::string &data, std::ostream &os, int level)
{
SharedBuffer<u8> databuf((u8*)data.c_str(), data.size());
- compressZlib(databuf, os);
+ compressZlib(databuf, os, level);
}
void decompressZlib(std::istream &is, std::ostream &os)