Solved

GZIP Decompression in memory

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 236
c++ getting the first 10 characters of a char* string 11 98
Least Squares Curve Fitting 4 97
Problem with SqlConnection 4 178
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

856 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