PostgreSQL Source Code  git master
crc32.c
Go to the documentation of this file.
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 ltree_crc32_sz(const char *buf, int size)
25 {
26  pg_crc32 crc;
27  const char *p = buf;
28 
30  while (size > 0)
31  {
32  char c = (char) TOLOWER(*p);
33 
35  size--;
36  p++;
37  }
39  return (unsigned int) crc;
40 }
unsigned int ltree_crc32_sz(const char *buf, int size)
Definition: crc32.c:24
#define TOLOWER(x)
Definition: crc32.c:15
return crc
uint32 pg_crc32
Definition: pg_crc.h:37
#define FIN_TRADITIONAL_CRC32(crc)
Definition: pg_crc.h:47
#define INIT_TRADITIONAL_CRC32(crc)
Definition: pg_crc.h:46
#define COMP_TRADITIONAL_CRC32(crc, data, len)
Definition: pg_crc.h:48
static char * buf
Definition: pg_test_fsync.c:73
char * c
static pg_noinline void Size size
Definition: slab.c:607