• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 764
  • Last Modified:

GZIP Decompression in memory

Currently I am saving a std::string to a file, and then using zlib to decompress that file using this code:

string gz_decompress(string compressedname){
      gzFile compressed = gzopen(compressedname.data(), "rb");
      if (!compressed) return "";
      char buffer[512];
      string decompressed;
      int num_read = 0;
      while ((num_read = gzread(compressed, buffer, sizeof(buffer))) > 0) {
            decompressed.append(buffer, num_read);
      }
      gzclose(compressed);
      return decompressed;
}

This is one of the slower parts of my program, and it seems like it would be more efficient to do the decompressing in memory.  I saw the example on codeproject, but was unable to get it to work.  If anyone could give me some code that will do this that would be great.

Thanks for any help
0
cx323
Asked:
cx323
1 Solution
 
Deepu AbrahamR & D Engineering ManagerCommented:
Did you try this:
http://www.codeproject.com/cpp/cgzip.asp
Best Regards,
DeepuAbrahamK
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now