Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Austrian Coder

Integrate compression

This topic is 5367 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I want to use zlib or lzo to update a programm with more functionality. It is a linux programm, but as this is the general programming forum this should be ok. I only need some help with my thouhts. These are the important functions: ssize_t safe_read(int filedes, void *buffer, size_t size) ssize_t safe_write(int filedes, const void *buffer, size_t size) I would say we discuss the safe_write function. It does wirte the buffer with the size into the file descriped by filedes. Now i want to use the compresson at this function: Easy or? Lets take the buffer and compress it like this way, note we need an temp buffer called out. int r = lzo1x_1_compress((unsigned char*)buffer, soize, out, &out_len, wrkmem); now the compressed sutff is in out. If i now only return the out buffer or make it via references (buffer = out). I will get memory problems and leakes, because i never free the out buffer. So whats the best solution. Has anyone some sourcecode about this topic (Include a compression lib and use it in combination of buffers). Thanks, Christian

Share this post

Link to post
Share on other sites
Let me get this straight. You are doing the following:

1. Allocate memory for buffer and out
2. Read into buffer
3. Compress buffer to out via lzo1x_1_compress()

What you would typically do then is simple;

4. Write soize, out_len and out
5. Delete buffer and out

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!