LCOV - code coverage report
Current view: top level - contrib/ltree - crc32.c (source / functions) Hit Total Coverage
Test: PostgreSQL 15devel Lines: 10 10 100.0 %
Date: 2021-12-05 02:08:31 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             : #include "ltree.h"
      12             : 
      13             : #ifdef LOWER_NODE
      14             : #include <ctype.h>
      15             : #define TOLOWER(x)  tolower((unsigned char) (x))
      16             : #else
      17             : #define TOLOWER(x)  (x)
      18             : #endif
      19             : 
      20             : #include "crc32.h"
      21             : #include "utils/pg_crc.h"
      22             : 
      23             : unsigned int
      24      312504 : ltree_crc32_sz(const char *buf, int size)
      25             : {
      26             :     pg_crc32    crc;
      27      312504 :     const char *p = buf;
      28             : 
      29      312504 :     INIT_TRADITIONAL_CRC32(crc);
      30      746556 :     while (size > 0)
      31             :     {
      32      434052 :         char        c = (char) TOLOWER(*p);
      33             : 
      34      868104 :         COMP_TRADITIONAL_CRC32(crc, &c, 1);
      35      434052 :         size--;
      36      434052 :         p++;
      37             :     }
      38      312504 :     FIN_TRADITIONAL_CRC32(crc);
      39      312504 :     return (unsigned int) crc;
      40             : }

Generated by: LCOV version 1.14