Solved

GZIP Decompression in memory

Posted on 2007-03-26
1
757 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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