Commit e0c572c5 authored by Wayne Davison's avatar Wayne Davison

Moved the flist_ndx_{push,pop}() routines from io.c into util.c.

parent 315c2152
......@@ -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);
......
......@@ -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 {
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment