Advertisement
Guest User

Untitled

a guest
Oct 4th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1.  
  2. void compressLZ4(const std::string &source, std::string &dest)
  3. {
  4. int str_s = source.size();
  5. char* buffer = new char[LZ4_compressBound(str_s)];
  6. int s = LZ4_compress(source.c_str(), buffer, str_s);
  7. dest = std::string(buffer,s);
  8. delete [] buffer;
  9. }
  10.  
  11. void decompressLZ4(const std::string &source, std::string &dest)
  12. {
  13. int maxLZ4bufferSize = source.size() * 255;
  14. char* buffer = new char[maxLZ4bufferSize];
  15. int s = LZ4_decompress_safe(source.c_str(), buffer,
  16. source.size(), maxLZ4bufferSize);
  17.  
  18. dest = std::string(buffer, s);
  19. delete [] buffer;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement