dedup

deduplicating backup program
git clone git://git.2f30.org/dedup.git
Log | Files | Refs | README | LICENSE

commit c3903829beb99b52fe47b86b42ee6cc9088948e2
parent dbce5b2dd7fee84e5d019f6146fe5bb7336aa9d5
Author: sin <sin@2f30.org>
Date:   Mon, 13 May 2019 22:55:17 +0100

Use bcompressops() directly

Diffstat:
Mblock.c | 44+++++++++-----------------------------------
1 file changed, 9 insertions(+), 35 deletions(-)

diff --git a/block.c b/block.c @@ -15,8 +15,6 @@ int bcreat(char *path, int mode, struct bctx **bctx) { - struct bops *bops; - if (path == NULL || bctx == NULL) { seterr("invalid params"); return -1; @@ -28,8 +26,7 @@ bcreat(char *path, int mode, struct bctx **bctx) return -1; } - bops = bcompressops(); - if (bops->creat(*bctx, path, mode) < 0) { + if (bcompressops()->creat(*bctx, path, mode) < 0) { free(*bctx); return -1; } @@ -39,8 +36,6 @@ bcreat(char *path, int mode, struct bctx **bctx) int bopen(char *path, int flags, int mode, struct bctx **bctx) { - struct bops *bops; - if (path == NULL || bctx == NULL) { seterr("invalid params"); return -1; @@ -52,8 +47,7 @@ bopen(char *path, int flags, int mode, struct bctx **bctx) return -1; } - bops = bcompressops(); - if (bops->open(*bctx, path, flags, mode) < 0) { + if (bcompressops()->open(*bctx, path, flags, mode) < 0) { free(*bctx); return -1; } @@ -63,91 +57,72 @@ bopen(char *path, int flags, int mode, struct bctx **bctx) int bput(struct bctx *bctx, void *buf, size_t n, unsigned char *md) { - struct bops *bops; - if (bctx == NULL || buf == NULL || n == 0 || md == NULL) { seterr("invalid params"); return -1; } - bops = bcompressops(); - return bops->put(bctx, buf, n, md); + return bcompressops()->put(bctx, buf, n, md); } int bget(struct bctx *bctx, unsigned char *md, void *buf, size_t *n) { - struct bops *bops; - if (bctx == NULL || md == NULL || buf == NULL || n == NULL) { seterr("invalid params"); return -1; } - bops = bcompressops(); - return bops->get(bctx, md, buf, n); + return bcompressops()->get(bctx, md, buf, n); } int brm(struct bctx *bctx, unsigned char *md) { - struct bops *bops; - if (bctx == NULL || md == NULL) { seterr("invalid params"); return -1; } - bops = bcompressops(); - return bops->rm(bctx, md); + return bcompressops()->rm(bctx, md); } int bgc(struct bctx *bctx) { - struct bops *bops; - if (bctx == NULL) { seterr("invalid params"); return -1; } - bops = bcompressops(); - return bops->gc(bctx); + return bcompressops()->gc(bctx); } int bcheck(struct bctx *bctx, unsigned char *md) { - struct bops *bops; - if (bctx == NULL || md == NULL) { seterr("invalid params"); return -1; } - bops = bcompressops(); - return bops->check(bctx, md); + return bcompressops()->check(bctx, md); } int bsync(struct bctx *bctx) { - struct bops *bops; - if (bctx == NULL) { seterr("invalid params"); return -1; } - bops = bcompressops(); - return bops->sync(bctx); + return bcompressops()->sync(bctx); } int bclose(struct bctx *bctx) { - struct bops *bops; int r; if (bctx == NULL) { @@ -157,8 +132,7 @@ bclose(struct bctx *bctx) if (bsync(bctx) < 0) return -1; - bops = bcompressops(); - r = bops->close(bctx); + r = bcompressops()->close(bctx); free(bctx); return r; }