dedup

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

commit 9c44b3cc69c31746ba4d8a16d04b444c639b4aa8
parent 9118f47ec13670c986b7cd59838c4fd8a8d7fc67
Author: sin <sin@2f30.org>
Date:   Thu, 25 Apr 2019 14:28:02 +0100

Re-order functions to be consistent with the block layer

Diffstat:
Msnap.c | 30+++++++++++++++---------------
Msnap.h | 2+-
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/snap.c b/snap.c @@ -167,39 +167,39 @@ sopen(char *path, int flags, int mode, struct sctx **sctx) } int -sget(struct sctx *sctx, unsigned char *md) +sput(struct sctx *sctx, unsigned char *md) { struct mdnode *mdnode; if (sctx == NULL || md == NULL) return -1; - mdnode = sctx->mdnext; + mdnode = calloc(1, sizeof(*mdnode)); if (mdnode == NULL) - mdnode = SLIST_FIRST(&sctx->mdhead); - else - mdnode = SLIST_NEXT(mdnode, e); - sctx->mdnext = mdnode; - if (mdnode != NULL) { - memcpy(md, mdnode->md, MDSIZE); - return MDSIZE; - } + return -1; + memcpy(mdnode->md, md, MDSIZE); + SLIST_INSERT_HEAD(&sctx->mdhead, mdnode, e); return 0; } int -sput(struct sctx *sctx, unsigned char *md) +sget(struct sctx *sctx, unsigned char *md) { struct mdnode *mdnode; if (sctx == NULL || md == NULL) return -1; - mdnode = calloc(1, sizeof(*mdnode)); + mdnode = sctx->mdnext; if (mdnode == NULL) - return -1; - memcpy(mdnode->md, md, MDSIZE); - SLIST_INSERT_HEAD(&sctx->mdhead, mdnode, e); + mdnode = SLIST_FIRST(&sctx->mdhead); + else + mdnode = SLIST_NEXT(mdnode, e); + sctx->mdnext = mdnode; + if (mdnode != NULL) { + memcpy(md, mdnode->md, MDSIZE); + return MDSIZE; + } return 0; } diff --git a/snap.h b/snap.h @@ -2,8 +2,8 @@ struct sctx; extern int screat(char *path, int mode, struct sctx **sctx); extern int sopen(char *path, int flags, int mode, struct sctx **sctx); -extern int sget(struct sctx *sctx, unsigned char *md); extern int sput(struct sctx *sctx, unsigned char *md); +extern int sget(struct sctx *sctx, unsigned char *md); extern int srewind(struct sctx *sctx); extern int ssync(struct sctx *sctx); extern int sclose(struct sctx *sctx);