X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/fe62d30de8d52fc8eb0e7efa3401226d68a9a868..a76ba8b4257cc75e99c71da7f44c5e75393a3d43:/util.c diff --git a/util.c b/util.c index 2f7ea914..4981d764 100644 --- a/util.c +++ b/util.c @@ -1621,6 +1621,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) {