add incremental crc calculation

re-using the enet code
This commit is contained in:
ac-stef
2015-02-08 17:39:15 +01:00
parent 84ae6f152e
commit 64f378154d
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -519,6 +519,7 @@ ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32);
ENET_API void enet_packet_destroy (ENetPacket *);
ENET_API int enet_packet_resize (ENetPacket *, size_t);
ENET_API enet_uint32 enet_crc32 (const ENetBuffer *, size_t);
ENET_API void enet_crc32_inc (enet_uint32 *crc, enet_uint8 byte);
ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32);
ENET_API void enet_host_destroy (ENetHost *);
+8
View File
@@ -161,4 +161,12 @@ enet_crc32 (const ENetBuffer * buffers, size_t bufferCount)
return ENET_HOST_TO_NET_32 (~ crc);
}
void
enet_crc32_inc (enet_uint32 *crc, enet_uint8 byte)
{
if (! initializedCRC32) initialize_crc32 ();
*crc = (*crc >> 8) ^ crcTable [(*crc & 0xFF) ^ byte];
}
/** @} */