Changeset 21919 in vbox
- Timestamp:
- Jul 31, 2009 3:43:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/checksum/crc32.cpp
r21337 r21919 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 87 87 #else 88 88 /** CRC32 feedback table. */ 89 uint32_tau32CRC32[] =89 static uint32_t const g_au32CRC32[] = 90 90 { 91 91 #endif … … 155 155 156 156 157 /**158 * Calculate CRC32 for a memory block.159 *160 * @returns CRC32 for the memory block.161 * @param pv Pointer to the memory block.162 * @param cb Size of the memory block in bytes.163 */164 157 RTDECL(uint32_t) RTCrc32(const void *pv, size_t cb) 165 158 { … … 167 160 uint32_t uCRC32 = ~0U; 168 161 while (cb--) 169 uCRC32 = au32CRC32[(uCRC32 ^ *pu8++) & 0xff] ^ (uCRC32 >> 8);162 uCRC32 = g_au32CRC32[(uCRC32 ^ *pu8++) & 0xff] ^ (uCRC32 >> 8); 170 163 return uCRC32 ^ ~0U; 171 164 } … … 173 166 174 167 175 /**176 * Start a multiblock CRC32 calculation.177 *178 * @returns Start CRC32.179 */180 168 RTDECL(uint32_t) RTCrc32Start(void) 181 169 { … … 185 173 186 174 187 /**188 * Processes a multiblock of a CRC32 calculation.189 *190 * @returns Intermediate CRC32 value.191 * @param uCRC32 Current CRC32 intermediate value.192 * @param pv The data block to process.193 * @param cb The size of the data block in bytes.194 */195 175 RTDECL(uint32_t) RTCrc32Process(uint32_t uCRC32, const void *pv, size_t cb) 196 176 { 197 177 const uint8_t *pu8 = (const uint8_t *)pv; 198 178 while (cb--) 199 uCRC32 = au32CRC32[(uCRC32 ^ *pu8++) & 0xff] ^ (uCRC32 >> 8);179 uCRC32 = g_au32CRC32[(uCRC32 ^ *pu8++) & 0xff] ^ (uCRC32 >> 8); 200 180 return uCRC32; 201 181 } … … 203 183 204 184 205 /**206 * Complete a multiblock CRC32 calculation.207 *208 * @returns CRC32 value.209 * @param uCRC32 Current CRC32 intermediate value.210 */211 185 RTDECL(uint32_t) RTCrc32Finish(uint32_t uCRC32) 212 186 {
Note:
See TracChangeset
for help on using the changeset viewer.