From: Wayne Davison Date: Sat, 27 Sep 2008 02:45:08 +0000 (-0700) Subject: Moved the flist_ndx_{push,pop}() routines from io.c into util.c. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/e0c572c5c691da243a3187f440daab739c0b3412?hp=315c2152d0a6fbd47690feb38b2410114038278f Moved the flist_ndx_{push,pop}() routines from io.c into util.c. --- diff --git a/io.c b/io.c index ed556b15..70756b8e 100644 --- a/io.c +++ b/io.c @@ -124,16 +124,7 @@ static void writefd(int fd, const char *buf, size_t len); static void writefd_unbuffered(int fd, const char *buf, size_t len); static void mplex_write(int fd, enum msgcode code, const char *buf, size_t len, int convert); -struct flist_ndx_item { - struct flist_ndx_item *next; - int ndx; -}; - -struct flist_ndx_list { - struct flist_ndx_item *head, *tail; -}; - -static struct flist_ndx_list redo_list, hlink_list; +static flist_ndx_list redo_list, hlink_list; struct msg_list_item { struct msg_list_item *next; @@ -147,39 +138,6 @@ struct msg_list { static struct msg_list msg_queue; -static void flist_ndx_push(struct flist_ndx_list *lp, int ndx) -{ - struct flist_ndx_item *item; - - if (!(item = new(struct flist_ndx_item))) - out_of_memory("flist_ndx_push"); - item->next = NULL; - item->ndx = ndx; - if (lp->tail) - lp->tail->next = item; - else - lp->head = item; - lp->tail = item; -} - -static int flist_ndx_pop(struct flist_ndx_list *lp) -{ - struct flist_ndx_item *next; - int ndx; - - if (!lp->head) - return -1; - - ndx = lp->head->ndx; - next = lp->head->next; - free(lp->head); - lp->head = next; - if (!next) - lp->tail = NULL; - - return ndx; -} - static void got_flist_entry_status(enum festatus status, const char *buf) { int ndx = IVAL(buf, 0); diff --git a/rsync.h b/rsync.h index 7eb9a807..c288a1fe 100644 --- a/rsync.h +++ b/rsync.h @@ -834,6 +834,15 @@ struct stats { struct chmod_mode_struct; +struct flist_ndx_item { + struct flist_ndx_item *next; + int ndx; +}; + +typedef struct { + struct flist_ndx_item *head, *tail; +} flist_ndx_list; + #define EMPTY_ITEM_LIST {NULL, 0, 0} typedef struct { diff --git a/util.c b/util.c index ea247751..6b075d0a 100644 --- a/util.c +++ b/util.c @@ -1540,6 +1540,39 @@ int bitbag_next_bit(struct bitbag *bb, int after) return -1; } +void flist_ndx_push(flist_ndx_list *lp, int ndx) +{ + struct flist_ndx_item *item; + + if (!(item = new(struct flist_ndx_item))) + out_of_memory("flist_ndx_push"); + item->next = NULL; + item->ndx = ndx; + if (lp->tail) + lp->tail->next = item; + else + lp->head = item; + lp->tail = item; +} + +int flist_ndx_pop(flist_ndx_list *lp) +{ + struct flist_ndx_item *next; + int ndx; + + if (!lp->head) + return -1; + + ndx = lp->head->ndx; + next = lp->head->next; + free(lp->head); + lp->head = next; + if (!next) + lp->tail = NULL; + + return ndx; +} + void *expand_item_list(item_list *lp, size_t item_size, const char *desc, int incr) {