LCOV - code coverage report
Current view: top level - src/server/protocol2/champ_chooser - scores.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 18 18 100.0 %
Date: 2019-07-31 11:35:18 Functions: 4 4 100.0 %

          Line data    Source code
       1             : #include "../../../burp.h"
       2             : #include "../../../alloc.h"
       3             : #include "scores.h"
       4             : 
       5           3 : struct scores *scores_alloc(void)
       6             : {
       7           3 :         return (struct scores *)calloc_w(1, sizeof(struct scores), __func__);
       8             : }
       9             : 
      10             : static void scores_free_content(struct scores *scores)
      11             : {
      12           3 :         if(!scores) return;
      13           3 :         free_v((void **)&scores->scores);
      14             : }
      15             : 
      16           3 : void scores_free(struct scores **scores)
      17             : {
      18           3 :         if(!scores) return;
      19           6 :         scores_free_content(*scores);
      20           3 :         free_v((void **)scores);
      21             : }
      22             : 
      23             : // Return -1 or error, 0 on OK.
      24          18 : int scores_grow(struct scores *scores, size_t count)
      25             : {
      26          18 :         if(!scores || !count) return 0;
      27          15 :         scores->size=count;
      28          15 :         if(!(scores->scores=(uint16_t *)realloc_w(scores->scores,
      29             :                 sizeof(uint16_t)*scores->size, __func__)))
      30             :                         return -1;
      31          14 :         return 0;
      32             : }
      33             : 
      34          17 : void scores_reset(struct scores *scores)
      35             : {
      36          17 :         if(!scores
      37          15 :           || !scores->scores
      38          14 :           || !scores->size)
      39             :                 return;
      40          14 :         memset(scores->scores, 0, sizeof(scores->scores[0])*scores->size);
      41             : }

Generated by: LCOV version 1.13