Guest User

Untitled

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