Line data Source code
1 : #include "../burp.h"
2 : #include "blist.h"
3 : #include "blk.h"
4 : #include "../alloc.h"
5 :
6 323 : struct blist *blist_alloc(void)
7 : {
8 323 : return (struct blist *)calloc_w(1, sizeof(struct blist), __func__);
9 : }
10 :
11 517 : void blist_free(struct blist **blist)
12 : {
13 : struct blk *b;
14 : struct blk *head;
15 711 : if(!blist || !*blist) return;
16 323 : b=(*blist)->head;
17 323 : head=b;
18 202907 : while(head)
19 : {
20 202261 : b=head;
21 202261 : head=head->next;
22 202261 : blk_free(&b);
23 : }
24 323 : free_v((void **)blist);
25 : }
26 :
27 222253 : void blist_add_blk(struct blist *blist, struct blk *blk)
28 : {
29 222253 : blk->index=++(blist->last_index);
30 :
31 222253 : if(blist->tail)
32 : {
33 : // Add to the end of the list.
34 222130 : blist->tail->next=blk;
35 222130 : blist->tail=blk;
36 : // Markers might have fallen off the end. Start them again
37 : // on the tail.
38 222130 : if(!blist->last_requested) blist->last_requested=blist->tail;
39 222130 : if(!blist->last_sent) blist->last_sent=blist->tail;
40 222253 : return;
41 : }
42 :
43 : // Start the list.
44 123 : blist->head=blk;
45 123 : blist->tail=blk;
46 : // Pointers to the head that can move along the list
47 : // at a different rate.
48 123 : blist->blk_for_champ_chooser=NULL;
49 123 : blist->blk_from_champ_chooser=blk;
50 123 : blist->last_requested=blk;
51 123 : blist->last_sent=blk;
52 123 : blist->blk_to_dedup=blk;
53 : }
|