+/* + * Calculate CRC32 of the given data. + */ +static inline pg_crc32 +crc32_sz(const char *buf, int size) +{ + pg_crc32 crc; + const char *p = buf; + + INIT_TRADITIONAL_CRC32(crc); + while (size > 0) + { + char c = (char) (*p); + + COMP_TRADITIONAL_CRC32(crc, &c, 1); + size--; + p++; + } + FIN_TRADITIONAL_CRC32(crc); + return crc; +}
I'm curious why we need to do this instead of only using the macros: INIT_TRADITIONAL_CRC32(crc); COMP_TRADITIONAL_CRC32(crc, VARDATA_ANY(in), len); FIN_TRADITIONAL_CRC32(crc); + * IDENTIFICATION + * src/backend/utils/adt/hashfuncs.c Perhaps these would fit into src/backend/utils/hash/pg_crc.c? -- nathan