URI: 
       Re-order functions to be consistent with the block layer - dedup - deduplicating backup program
  HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 9c44b3cc69c31746ba4d8a16d04b444c639b4aa8
   DIR parent 9118f47ec13670c986b7cd59838c4fd8a8d7fc67
  HTML 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:
         M snap.c                              |      30 +++++++++++++++---------------
         M snap.h                              |       2 +-
       
       2 files changed, 16 insertions(+), 16 deletions(-)
       ---
   DIR 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;
        }
        
   DIR 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);