Solved

GZIP Decompression in memory

Posted on 2007-03-26
1
754 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

895 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