2 * Functions for dealing with linked lists of goodies
4 * @(#)list.c 3.3 (Berkeley) 6/15/81
6 * Rogue: Exploring the Cavern of Cuties
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * See the file LICENSE.TXT for full copyright and licensing information.
20 * Takes an item out of whatever linked list it might be in
24 register struct linked_list
**list
, *item
;
28 if (prev(item
) != NULL
) item
->l_prev
->l_next
= next(item
);
29 if (next(item
) != NULL
) item
->l_next
->l_prev
= prev(item
);
36 * add an item to the head of a list
40 register struct linked_list
**list
, *item
;
45 (*list
)->l_prev
= item
;
59 * Throw the whole blamed thing away
63 register struct linked_list
**ptr
;
65 register struct linked_list
*item
;
81 register struct linked_list
*item
;
90 * get a new item with a specified size
97 register struct linked_list
*item
;
99 if ((item
= (struct linked_list
*) new(sizeof *item
)) == NULL
)
100 msg("Ran out of memory for header after %d items", total
);
101 if ((item
->l_data
= new(size
)) == NULL
)
102 msg("Ran out of memory for data after %d items", total
);
103 item
->l_next
= item
->l_prev
= NULL
;
104 memset(item
->l_data
,0,size
);
112 register char *space
= ALLOC(size
);
116 sprintf(prbuf
, "Rogue ran out of memory (%d). Fatal error!", md_memused());