LCOV - code coverage report
Current view: top level - src/detail - ppg_compression_detail.c (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 19 19 100.0 %
Date: 2018-01-08 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* Copyright 2017 noseglasses <shinynoseglasses@gmail.com>
       2             :  *
       3             :  * This program is free software: you can redistribute it and/or modify
       4             :  * it under the terms of the GNU Lesser General Public License as published by
       5             :  * the Free Software Foundation, either version 3 of the License, or
       6             :  * (at your option) any later version.
       7             :  *
       8             :  * This program is distributed in the hope that it will be useful,
       9             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      10             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      11             :  * GNU Lesser General Public License for more details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
      15             :  */
      16             : 
      17             : #include "detail/ppg_compression_detail.h"
      18             : #include "ppg_debug.h"
      19             : 
      20             : #include "assert.h"
      21             : 
      22        2094 : int ppg_compression_check_symbol_registered(PPG_Compression_Context__ *ccontext,
      23             :                                             void *symbol)
      24             : {
      25        2094 :    int s = 0;
      26        8126 :    for(; s < (int)ccontext->symbols_lookup.n_stored; ++s) {
      27             :       
      28             : //          printf("Checking symbol %s\n", ccontext->symbols_lookup.buffer[s].name);
      29             : //          printf("   Stored symbol %p\n", ccontext->symbols_lookup.buffer[s].address);
      30             : //          printf("   Checking symbol %p\n", symbol);
      31             :       
      32        7488 :       if(ccontext->symbols_lookup.buffer[s].address == symbol) {
      33        1456 :          break;
      34             :       }
      35             :    }
      36             :    
      37        2094 :    if(!(s < (int)ccontext->symbols_lookup.n_stored)) {
      38         638 :       s = -1;
      39             :    }
      40             :    
      41        2094 :    return s;
      42             : }
      43             : 
      44        1596 : void ppg_compression_context_register_symbol(void **symbol,
      45             :                                              PPG_Compression_Context__ *ccontext)
      46             : {
      47        1596 :    PPG_ASSERT(symbol);
      48             :    
      49        1596 :    if(!(*symbol)) {
      50         230 :       return;
      51             :    }
      52             :    
      53        1366 :    PPG_ASSERT(ccontext->symbols);
      54        1366 :    PPG_ASSERT(ccontext->n_symbols < ccontext->n_symbols_space);
      55             :    
      56        1366 :    int s = ppg_compression_check_symbol_registered(ccontext, *symbol);
      57             :    
      58        1366 :    if(s < 0) {
      59         638 :       PPG_LOG("Symbol %p unregistered\n", *symbol);
      60             :    }
      61             :    else {
      62             :    
      63         728 :       ccontext->symbols[ccontext->n_symbols] = symbol;
      64             :       
      65         728 :       ++ccontext->n_symbols;
      66             :    }
      67             : }
      68             : 
      69             : // void ppg_compression_context_register_vptr(void **vptr,
      70             : //                                           PPG_Compression_Context__ *ccontext)
      71             : // {
      72             : //    PPG_ASSERT(ccontext->vptrs);
      73             : //    PPG_ASSERT(ccontext->n_vptrs < ccontext->n_vptrs_space);
      74             : //    
      75             : //    ccontext->vptrs[ccontext->n_vptrs] = vptr;
      76             : //    
      77             : //    ++ccontext->n_vptrs;
      78             : // }

Generated by: LCOV version 1.10