]> git.lizzy.rs Git - minetest.git/blobdiff - src/serialization.cpp
Fix memory leaks due to messed up memory handling for particles as well as their...
[minetest.git] / src / serialization.cpp
index e79342432dc2168806599fe63fdd44357053d970..c0fbe10e23335fb9cc8f2031dd8637e0cec548a3 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Minetest
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -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)