mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
7e735035f2
The basic rule we follow here is to always first include 'postgres.h' or 'postgres_fe.h' whichever is applicable, then system header includes and then Postgres header includes. In this, we also follow that all the Postgres header includes are in order based on their ASCII value. We generally follow these rules, but the code has deviated in many places. This commit makes it consistent just for contrib modules. The later commits will enforce similar rules in other parts of code. Author: Vignesh C Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/CALDaNm2Sznv8RR6Ex-iJO6xAdsxgWhCoETkaYX=+9DW3q0QCfA@mail.gmail.com
40 lines
667 B
C
40 lines
667 B
C
/* contrib/ltree/crc32.c */
|
|
|
|
/*
|
|
* Implements CRC-32, as used in ltree.
|
|
*
|
|
* Note that the CRC is used in the on-disk format of GiST indexes, so we
|
|
* must stay backwards-compatible!
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
#ifdef LOWER_NODE
|
|
#include <ctype.h>
|
|
#define TOLOWER(x) tolower((unsigned char) (x))
|
|
#else
|
|
#define TOLOWER(x) (x)
|
|
#endif
|
|
|
|
#include "crc32.h"
|
|
#include "utils/pg_crc.h"
|
|
|
|
unsigned int
|
|
ltree_crc32_sz(char *buf, int size)
|
|
{
|
|
pg_crc32 crc;
|
|
char *p = buf;
|
|
|
|
INIT_TRADITIONAL_CRC32(crc);
|
|
while (size > 0)
|
|
{
|
|
char c = (char) TOLOWER(*p);
|
|
|
|
COMP_TRADITIONAL_CRC32(crc, &c, 1);
|
|
size--;
|
|
p++;
|
|
}
|
|
FIN_TRADITIONAL_CRC32(crc);
|
|
return (unsigned int) crc;
|
|
}
|