X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/315c2152d0a6fbd47690feb38b2410114038278f..e0c572c5c691da243a3187f440daab739c0b3412:/util.c 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) {