Line data Source code
1 : #include "../burp.h"
2 : #include "blist.h"
3 : #include "blk.h"
4 : #include "../alloc.h"
5 :
6 326 : struct blist *blist_alloc(void)
7 : {
8 326 : return (struct blist *)calloc_w(1, sizeof(struct blist), __func__);
9 : }
10 :
11 662 : void blist_free(struct blist **blist)
12 : {
13 : struct blk *b;
14 : struct blk *head;
15 998 : if(!blist || !*blist) return;
16 326 : b=(*blist)->head;
17 326 : head=b;
18 203158 : while(head)
19 : {
20 202506 : b=head;
21 202506 : head=head->next;
22 202506 : blk_free(&b);
23 : }
24 326 : free_v((void **)blist);
25 : }
26 :
27 227580 : void blist_add_blk(struct blist *blist, struct blk *blk)
28 : {
29 227580 : blk->index=++(blist->last_index);
30 :
31 227580 : 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 227580 : return;
41 : }
42 :
43 : // Start the list.
44 124 : blist->head=blk;
45 124 : blist->tail=blk;
46 : // Pointers to the head that can move along the list
47 : // at a different rate.
48 124 : blist->blk_for_champ_chooser=NULL;
49 124 : blist->blk_from_champ_chooser=blk;
50 124 : blist->last_requested=blk;
51 124 : blist->last_sent=blk;
52 124 : blist->blk_to_dedup=blk;
53 : }
|