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