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: 22 22 100.0 %
Date: 2015-11-30 Functions: 5 5 100.0 %

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

Generated by: LCOV version 1.10