LCOV - code coverage report
Current view: top level - src/leveldb/util - crc32c.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 8 8 100.0 %
Date: 2022-04-21 14:51:19 Functions: 3 3 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
#       2                 :            : // Use of this source code is governed by a BSD-style license that can be
#       3                 :            : // found in the LICENSE file. See the AUTHORS file for names of contributors.
#       4                 :            : 
#       5                 :            : #ifndef STORAGE_LEVELDB_UTIL_CRC32C_H_
#       6                 :            : #define STORAGE_LEVELDB_UTIL_CRC32C_H_
#       7                 :            : 
#       8                 :            : #include <stddef.h>
#       9                 :            : #include <stdint.h>
#      10                 :            : 
#      11                 :            : namespace leveldb {
#      12                 :            : namespace crc32c {
#      13                 :            : 
#      14                 :            : // Return the crc32c of concat(A, data[0,n-1]) where init_crc is the
#      15                 :            : // crc32c of some string A.  Extend() is often used to maintain the
#      16                 :            : // crc32c of a stream of data.
#      17                 :            : uint32_t Extend(uint32_t init_crc, const char* data, size_t n);
#      18                 :            : 
#      19                 :            : // Return the crc32c of data[0,n-1]
#      20                 :      70836 : inline uint32_t Value(const char* data, size_t n) { return Extend(0, data, n); }
#      21                 :            : 
#      22                 :            : static const uint32_t kMaskDelta = 0xa282ead8ul;
#      23                 :            : 
#      24                 :            : // Return a masked representation of crc.
#      25                 :            : //
#      26                 :            : // Motivation: it is problematic to compute the CRC of a string that
#      27                 :            : // contains embedded CRCs.  Therefore we recommend that CRCs stored
#      28                 :            : // somewhere (e.g., in files) should be masked before being stored.
#      29                 :      27832 : inline uint32_t Mask(uint32_t crc) {
#      30                 :            :   // Rotate right by 15 bits and add a constant.
#      31                 :      27832 :   return ((crc >> 15) | (crc << 17)) + kMaskDelta;
#      32                 :      27832 : }
#      33                 :            : 
#      34                 :            : // Return the crc whose masked representation is masked_crc.
#      35                 :      34932 : inline uint32_t Unmask(uint32_t masked_crc) {
#      36                 :      34932 :   uint32_t rot = masked_crc - kMaskDelta;
#      37                 :      34932 :   return ((rot >> 17) | (rot << 15));
#      38                 :      34932 : }
#      39                 :            : 
#      40                 :            : }  // namespace crc32c
#      41                 :            : }  // namespace leveldb
#      42                 :            : 
#      43                 :            : #endif  // STORAGE_LEVELDB_UTIL_CRC32C_H_

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a