LCOV - code coverage report
Current view: top level - contrib/ltree - crc32.c (source / functions) Hit Total Coverage
Test: PostgreSQL 12devel Lines: 10 10 100.0 %
Date: 2018-12-15 21:21:55 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* contrib/ltree/crc32.c */
       2             : 
       3             : /*
       4             :  * Implements CRC-32, as used in ltree.
       5             :  *
       6             :  * Note that the CRC is used in the on-disk format of GiST indexes, so we
       7             :  * must stay backwards-compatible!
       8             :  */
       9             : 
      10             : #include "postgres.h"
      11             : 
      12             : #ifdef LOWER_NODE
      13             : #include <ctype.h>
      14             : #define TOLOWER(x)  tolower((unsigned char) (x))
      15             : #else
      16             : #define TOLOWER(x)  (x)
      17             : #endif
      18             : 
      19             : #include "utils/pg_crc.h"
      20             : #include "crc32.h"
      21             : 
      22             : unsigned int
      23       81162 : ltree_crc32_sz(char *buf, int size)
      24             : {
      25             :     pg_crc32    crc;
      26       81162 :     char       *p = buf;
      27             : 
      28       81162 :     INIT_TRADITIONAL_CRC32(crc);
      29      297798 :     while (size > 0)
      30             :     {
      31      135474 :         char        c = (char) TOLOWER(*p);
      32             : 
      33      135474 :         COMP_TRADITIONAL_CRC32(crc, &c, 1);
      34      135474 :         size--;
      35      135474 :         p++;
      36             :     }
      37       81162 :     FIN_TRADITIONAL_CRC32(crc);
      38       81162 :     return (unsigned int) crc;
      39             : }

Generated by: LCOV version 1.13