Push the free out of flush_chunk(), then the caller just does it
instead. Unifies the log write vs compress as well.
Signed-off-by: Jens Axboe <axboe@fb.com>
void *buf;
size_t len;
unsigned int seq;
void *buf;
size_t len;
unsigned int seq;
};
#define GZ_CHUNK 131072
};
#define GZ_CHUNK 131072
c->buf = malloc(GZ_CHUNK);
c->len = 0;
c->seq = seq;
c->buf = malloc(GZ_CHUNK);
c->len = 0;
c->seq = seq;
return c;
}
static void free_chunk(struct iolog_compress *ic)
{
return c;
}
static void free_chunk(struct iolog_compress *ic)
{
- if (!ic->nofree) {
- free(ic->buf);
- free(ic);
- }
+ free(ic->buf);
+ free(ic);
}
static int z_stream_init(z_stream *stream, int gz_hdr)
}
static int z_stream_init(z_stream *stream, int gz_hdr)
ic = flist_entry(node, struct iolog_compress, list);
flist_del(&ic->list);
ic = flist_entry(node, struct iolog_compress, list);
flist_del(&ic->list);
- if (log->log_gz_store) {
fwrite(ic->buf, ic->len, 1, f);
fwrite(ic->buf, ic->len, 1, f);
- free_chunk(ic);
- } else
flush_chunk(ic, log->log_gz_store, f, &stream, &iter);
flush_chunk(ic, log->log_gz_store, f, &stream, &iter);
ic.buf = malloc(sb.st_size);
ic.len = sb.st_size;
ic.buf = malloc(sb.st_size);
ic.len = sb.st_size;
ic.seq = 1;
ret = fread(ic.buf, ic.len, 1, f);
ic.seq = 1;
ret = fread(ic.buf, ic.len, 1, f);