Solved

GZIP Decompression in memory

Posted on 2007-03-26
1
753 Views
Last Modified: 2008-03-10
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
Comment
Question by:cx323
1 Comment
 
LVL 11

Accepted Solution

by:
DeepuAbrahamK earned 500 total points
ID: 18797940
Did you try this:
http://www.codeproject.com/cpp/cgzip.asp
Best Regards,
DeepuAbrahamK
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now