aboutsummaryrefslogtreecommitdiff
path: root/lib/comp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/comp')
-rw-r--r--lib/comp/block_processor.c2
-rw-r--r--lib/comp/block_processor_parallel.c11
-rw-r--r--lib/comp/create_block.c2
-rw-r--r--lib/comp/internal.h1
-rw-r--r--lib/comp/lzo.c4
5 files changed, 9 insertions, 11 deletions
diff --git a/lib/comp/block_processor.c b/lib/comp/block_processor.c
index 5938b3a..06dc384 100644
--- a/lib/comp/block_processor.c
+++ b/lib/comp/block_processor.c
@@ -29,7 +29,7 @@ block_processor_t *block_processor_create(size_t max_block_size,
void *user,
block_cb callback)
{
- block_processor_t *proc = calloc(1, sizeof(*proc) + max_block_size);
+ block_processor_t *proc = alloc_flex(sizeof(*proc), 1, max_block_size);
(void)num_workers;
if (proc == NULL) {
diff --git a/lib/comp/block_processor_parallel.c b/lib/comp/block_processor_parallel.c
index 985c900..b58ad5c 100644
--- a/lib/comp/block_processor_parallel.c
+++ b/lib/comp/block_processor_parallel.c
@@ -119,15 +119,13 @@ block_processor_t *block_processor_create(size_t max_block_size,
{
block_processor_t *proc;
unsigned int i;
- size_t size;
int ret;
if (num_workers < 1)
num_workers = 1;
- size = sizeof(proc->workers[0]) * num_workers;
-
- proc = calloc(1, sizeof(*proc) + size);
+ proc = alloc_flex(sizeof(*proc),
+ sizeof(proc->workers[0]), num_workers);
if (proc == NULL) {
perror("Creating block processor");
return NULL;
@@ -153,10 +151,9 @@ block_processor_t *block_processor_create(size_t max_block_size,
goto fail_cond;
}
- size = sizeof(compress_worker_t) + max_block_size;
-
for (i = 0; i < num_workers; ++i) {
- proc->workers[i] = calloc(1, size);
+ proc->workers[i] = alloc_flex(sizeof(compress_worker_t),
+ 1, max_block_size);
if (proc->workers[i] == NULL) {
perror("Creating block worker data");
diff --git a/lib/comp/create_block.c b/lib/comp/create_block.c
index e410091..90344bb 100644
--- a/lib/comp/create_block.c
+++ b/lib/comp/create_block.c
@@ -16,7 +16,7 @@
block_t *create_block(const char *filename, int fd, size_t size,
void *user, uint32_t flags)
{
- block_t *blk = calloc(1, sizeof(*blk) + size);
+ block_t *blk = alloc_flex(sizeof(*blk), 1, size);
if (blk == NULL) {
perror(filename);
diff --git a/lib/comp/internal.h b/lib/comp/internal.h
index 6bcd8fc..986266d 100644
--- a/lib/comp/internal.h
+++ b/lib/comp/internal.h
@@ -10,6 +10,7 @@
#include "config.h"
#include "compress.h"
+#include "util.h"
int generic_write_options(int fd, const void *data, size_t size);
diff --git a/lib/comp/lzo.c b/lib/comp/lzo.c
index 66c2f59..09ef75c 100644
--- a/lib/comp/lzo.c
+++ b/lib/comp/lzo.c
@@ -182,7 +182,7 @@ static compressor_t *lzo_create_copy(compressor_t *cmp)
lzo_compressor_t *other = (lzo_compressor_t *)cmp;
lzo_compressor_t *lzo;
- lzo = calloc(1, sizeof(*lzo) + lzo_algs[other->algorithm].bufsize);
+ lzo = alloc_flex(sizeof(*lzo), 1, lzo_algs[other->algorithm].bufsize);
if (lzo == NULL) {
perror("creating additional lzo compressor");
@@ -282,7 +282,7 @@ compressor_t *create_lzo_compressor(bool compress, size_t block_size,
if (options != NULL && process_options(options, &alg, &level) != 0)
return NULL;
- lzo = calloc(1, sizeof(*lzo) + lzo_algs[alg].bufsize);
+ lzo = alloc_flex(sizeof(*lzo), 1, lzo_algs[alg].bufsize);
base = (compressor_t *)lzo;
if (lzo == NULL) {