   Integrate compression
  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 
  Let me get this straight. You are doing the following:1. Allocate memory for buffer and out2. Read into buffer3. Compress buffer to out via lzo1x_1_compress()What you would typically do then is simple;4. Write soize, out_len and out5. Delete buffer and out 