zlib data errors
I use zlib to write data structures to a compressed file, using the
gzwrite function. Afterwards I read the data back with gzread. I notice that this works well when the data written is not that much, but when there is more data to write, after a while I get data errors when reading back the data. Error in main: couldn't read stat zlib error -3: test512-20070531-18h10m02.stat.gz: data error I wonder whether I am doing something wrong. The data I write are simply C data structures, struct acmp_stat, which have a fixed size. I am using my internal buffer, after noticing that it helped the problem. However, now, even though I buffer I get problems. Writing is done with: Code:
if (data->buflen + sizeof(*s) > data->bufmaxlen) Code:
struct acmp_data { Code:
static int and acmp_buffer_stat simply: Code:
static void Of course I have opened and closed the file before and after using this code. The buffer is currently assigned a size of 1 MiB. Reading back the data is done with: Code:
static int The code looks ok to me, and the weird thing is that I only get errors when the amount of data written is large. I didn't find a clear point yet, from where it seems to fail. Also notice that there are no errors when writing, but only when reading back. The files are not touched between reading and writing, and are cleanly closed. Am I doing something wrong here? Thanks a lot, Thomas |
Does anyone have an idea for this?
Thanks, Thomas |
All times are GMT -5. The time now is 07:18 PM. |