postgresql/contrib/ltree/crc32.c
Amit Kapila 7e735035f2 Make the order of the header file includes consistent in contrib modules.
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
2019-10-24 08:05:34 +05:30

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;
}