PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 
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 ltree_crc32_sz(char *buf, int size)
24 {
25  pg_crc32 crc;
26  char *p = buf;
27 
29  while (size > 0)
30  {
31  char c = (char) TOLOWER(*p);
32 
33  COMP_TRADITIONAL_CRC32(crc, &c, 1);
34  size--;
35  p++;
36  }
38  return (unsigned int) crc;
39 }
unsigned int ltree_crc32_sz(char *buf, int size)
Definition: crc32.c:23
#define COMP_TRADITIONAL_CRC32(crc, data, len)
Definition: pg_crc.h:48
#define TOLOWER(x)
Definition: crc32.c:16
#define INIT_TRADITIONAL_CRC32(crc)
Definition: pg_crc.h:46
char * c
static char * buf
Definition: pg_test_fsync.c:66
#define FIN_TRADITIONAL_CRC32(crc)
Definition: pg_crc.h:47
uint32 pg_crc32
Definition: pg_crc.h:37