LCOV - code coverage report
Current view: top level - src - slist.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 29 30 96.7 %
Date: 2015-10-31 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "burp.h"
       2             : #include "alloc.h"
       3             : #include "sbuf.h"
       4             : #include "slist.h"
       5             : #include "protocol2/blist.h"
       6             : 
       7         253 : struct slist *slist_alloc(void)
       8             : {
       9         253 :         struct slist *slist=NULL;
      10         759 :         if(!(slist=(struct slist *)calloc_w(1, sizeof(struct slist), __func__))
      11         506 :           || !(slist->blist=blist_alloc()))
      12           0 :                 slist_free(&slist);
      13         253 :         return slist;
      14             : }
      15             : 
      16         253 : void slist_free(struct slist **slist)
      17             : {
      18             :         struct sbuf *sb;
      19             :         struct sbuf *shead;
      20         506 :         if(!slist || !*slist) return;
      21         253 :         blist_free(&(*slist)->blist);
      22         253 :         shead=(*slist)->head;
      23       24450 :         while(shead)
      24             :         {
      25       23944 :                 sb=shead;
      26       23944 :                 shead=shead->next;
      27       23944 :                 sbuf_free(&sb);
      28             :         }
      29         253 :         free_v((void **)slist);
      30             : }
      31             : 
      32       23944 : void slist_add_sbuf(struct slist *slist, struct sbuf *sb)
      33             : {
      34       23944 :         if(slist->tail)
      35             :         {
      36             :                 // Add to the end of the list.
      37       23699 :                 slist->tail->next=sb;
      38       23699 :                 slist->tail=sb;
      39             :                 // Markers might have fallen off the end. Start them again
      40             :                 // on the tail.
      41       23699 :                 if(!slist->last_requested) slist->last_requested=slist->tail;
      42       23699 :                 if(!slist->add_sigs_here) slist->add_sigs_here=slist->tail;
      43       23699 :                 if(!slist->blks_to_request) slist->blks_to_request=slist->tail;
      44       23699 :                 if(!slist->blks_to_send) slist->blks_to_send=slist->tail;
      45             :         }
      46             :         else
      47             :         {
      48             :                 // Start the list.
      49         245 :                 slist->head=sb;
      50         245 :                 slist->tail=sb;
      51             :                 // Pointers to the head that can move along the list
      52             :                 // at a different rate.
      53         245 :                 slist->last_requested=sb;
      54         245 :                 slist->add_sigs_here=sb;
      55         245 :                 slist->blks_to_request=sb;
      56         245 :                 slist->blks_to_send=sb;
      57             :         }
      58       23944 : }

Generated by: LCOV version 1.10